1use warnings; 2use strict; 3 4# Test User::Identity::Location 5 6use Test::More tests => 30; 7 8BEGIN { use_ok('User::Identity::Location') }; 9 10my $ui = 'User::Identity'; 11my $uil = 'User::Identity::Location'; 12 13# 14# We need a user to test with 15# 16 17my $a = $ui->new('markov' 18 , firstname => 'Mark', surname => 'Overmeer' 19 , titles => 'drs.', initials => 'M.A.C.J.' 20 , language => 'nl-NL', charset => 'iso-8859-15' 21 , gender => 'male', birth => 'April 5, 1966' 22 ); 23 24ok(defined $a, "Create a"); 25 26# 27# Now an location 28# 29 30my $b = $uil->new 31 ( 'home' 32 , street => 'Pad 12' 33 , postal_code => '66341 XA' 34 , city => 'Arnhem' 35 , country => 'Nederland' 36 , country_code => 'nl' 37 , phone => '+18-12-2344556' 38 , fax => '+11-11-2344556' 39 ); 40 41ok(defined $b); 42isa_ok($b, $uil, "Create b"); 43is($b->street, 'Pad 12'); 44is($b->postalCode, '66341 XA'); 45is($b->city, 'Arnhem'); 46is($b->country, 'Nederland'); 47is($b->countryCode, 'nl'); 48is($b->phone, '+18-12-2344556'); 49is($b->fax, '+11-11-2344556'); 50 51ok(defined $b->parent($a), "Add location to user"); 52isa_ok($b->parent, $ui); 53is($b->user->firstname, 'Mark'); 54 55is($b->fullAddress, <<'NL'); 56Pad 12 576341 XA Arnhem 58Nederland 59NL 60 61# 62# more complex situations 63# 64 65my $c = $uil->new 66 ( 'work' 67 , organization => 'MARKOV Solutions' 68 , pobox => 'Postbus 12' 69 , pobox_pc => '3412YY' 70 , city => 'XYZ' 71 , country_code => 'nl' 72 , phone => [ '1', '2' ] 73 , fax => [ '3', '4', '5', '6' ] 74 ); 75 76ok(defined $c, "Created c"); 77is($c->countryCode, 'nl'); 78is($c->organization, 'MARKOV Solutions'); 79is($c->pobox, 'Postbus 12'); 80is($c->poboxPostalCode, '3412YY'); 81is($c->city, 'XYZ'); 82 83is(scalar $c->phone, '1'); 84my @ct = $c->phone; 85cmp_ok(scalar @ct, '==', 2); 86is($ct[0], '1'); 87is($ct[1], '2'); 88 89is(scalar $c->fax, '3'); 90my @cf = $c->fax; 91cmp_ok(scalar @cf, '==', 4); 92is($cf[0], '3'); 93is($cf[3], '6'); 94 95eval 'require Geography::Countries'; 96my $country = $@ ? 'NL' : 'Netherlands'; 97 98is($c->fullAddress, <<NL); 99MARKOV Solutions 100Postbus 12 1013412 YY XYZ 102$country 103NL 104