#!/usr/bin/perl use strict; use warnings; #use Data::Dumper; use Test::Simple tests => 12; use DB::Countries; my $country = new DB::Countries; my $to_insert = { country => 'Testunien', country_code => 'TST' }; my $inserted = $country->insert($to_insert); my $to_update = { country => 'Lummerland', country_code => 'LUM', ID_country => $inserted }; ok (defined $inserted, '$inserted is defined'); ok ($inserted =~ m/^\d+$/, '$inserted is a numerical id'); my $response = $country->get($inserted); ok (defined $response, '$response is defined'); ok (ref $response eq 'ARRAY', '$response is a reference to an array'); ok ($response->[0]->{country} eq 'Testunien', '$response->[0]->{country} has expected value: "Testunien"'); ok ($response->[0]->{country_code} eq 'TST', '$response->[0]->{country_code} has expected value: "TST"'); ok ($country->update($to_update), '$country->update($to_update) called and succeeded'); $response = $country->get($inserted); ok (defined $response, '$response is defined'); ok (ref $response eq 'ARRAY', '$response is a reference to an array'); ok ($response->[0]->{country} eq 'Lummerland', '$response->[0]->{country} has expected value: "Lummerland"'); ok ($response->[0]->{country_code} eq 'LUM', '$response->[0]->{country_code} has expected value: "LUM"'); ok ($country->remove($inserted), '$country->remove($inserted) called and succeeded'); exit;