# -*- perl -*- # Copyright (C) 2004 Identity Commons. All Rights Reserved. # See LICENSE for licensing details # Authors: # Fen Labalme , # Eugene Eric Kim use Test::More; plan tests => scalar keys(%tests) + 5; use XRI::Descriptor; while (my ($name, $test) = each %tests) { ($function = $name) =~ s/^([^\d]*)\d*$/$1/; my ($xml, $expected) = @$test; my $xd = XRI::Descriptor->new( $xml ); my $result = $xd->$function; if ( ref $expected ) { is_deeply($result, $expected, $name); } else { is($result, $expected, $name); } } # LocalAccess test. Can't use the %test hash because getLocalAccess # returns a list of objects. my $xd = XRI::Descriptor->new($localAccessTest); my @localAccess = $xd->getLocalAccess; is(scalar @localAccess, 1); isa_ok($localAccess[0], 'XRI::Descriptor::LocalAccess'); is(scalar @{$localAccess[0]->uris}, 2); is(${$localAccess[0]->uris}[0], 'testuri'); is(${$localAccess[0]->uris}[1], 'test2uri'); BEGIN { ## ## the format used for tests is: ## 1. method (with optional digit to separate tests) ## 2. array of [ descriptor, test_result ] ## %tests = ( getResolved => [ ' .foo testuri ', ".foo" ], getXRIAuthorityURIs1 => [ ' .foo testuri ', ['testuri'] ], getXRIAuthorityURIs2 => [ ' .foo testuri test2uri ', ['testuri', 'test2uri'] ], getMappings => [ ' .foo xri:=Foo xri:1.2.3 ', ['xri:=Foo', 'xri:1.2.3'] ], getXRIAuthorityURIs3 => [ ' @ http://localhost/xri/at ', [ 'http://localhost/xri/at' ]], ); $localAccessTest = ' .foo testuri test2uri '; }