3 # This Koha test module is a stub!
4 # Add more tests here!!!
9 use Test::More tests => 5;
14 use_ok('C4::AuthoritiesMarc');
17 # We are now going to be testing the authorities hierarchy code, and
18 # therefore need to pretend that we have consistent data in our database
19 my $module = new Test::MockModule('C4::AuthoritiesMarc');
20 $module->mock('GetHeaderAuthority', sub {
21 return {'authtrees' => ''};
23 $module->mock('AddAuthorityTrees', sub {
26 $module->mock('GetAuthority', sub {
28 my $record = MARC::Record->new();
32 [ '151', ' ', ' ', a => 'United States' ]
34 } elsif ($authid eq '2') {
37 [ '151', ' ', ' ', a => 'New York (State)' ],
38 [ '551', ' ', ' ', a => 'United States', w => 'g', 9 => '1' ]
40 } elsif ($authid eq '3') {
43 [ '151', ' ', ' ', a => 'New York (City)' ],
44 [ '551', ' ', ' ', a => 'New York (State)', w => 'g', 9 => '2' ]
46 } elsif ($authid eq '4') {
49 [ '151', ' ', ' ', a => 'New York (City)' ],
50 [ '551', ' ', ' ', a => 'New York (State)', w => 'g' ]
58 is(BuildAuthHierarchies(3, 1), '1,2,3', "Built linked authtrees hierarchy string");
60 my $expectedhierarchy = [ [ {
62 'value' => 'United States',
66 'value' => 'New York (State)',
71 'value' => 'New York (City)',
76 'value' => 'New York (State)'
81 'value' => 'United States'
87 is_deeply(GenerateHierarchy(3), $expectedhierarchy, "Generated hierarchy data structure for linked hierarchy");
89 is(BuildAuthHierarchies(4, 1), '4', "Built unlinked authtrees hierarchy string");
90 $expectedhierarchy = [ [ {
93 'value' => 'New York (City)',
98 is_deeply(GenerateHierarchy(4), $expectedhierarchy, "Generated hierarchy data structure for unlinked hierarchy");