8 use Test
::More tests
=> 11;
11 use_ok
('C4::Members::Attributes', qw(:all));
15 $C4::Members
::Attributes
::AttributeTypes
= {
17 'opac_display' => '1',
18 'staff_searchable' => '1',
19 'description' => 'Grade level',
20 'authorised_value_category' => '',
26 'opac_display' => '0',
27 'staff_searchable' => '1',
28 'description' => 'Deans List (annual)',
29 'authorised_value_category' => '',
31 'code' => 'deanslist',
35 'opac_display' => '0',
36 'staff_searchable' => '0',
37 'description' => 'Some Ext. Attribute',
38 'authorised_value_category' => '',
44 'opac_display' => '0',
45 'staff_searchable' => '0',
46 'description' => 'Another Ext. Attribute',
47 'authorised_value_category' => '',
49 'code' => 'extradata',
53 'opac_display' => '1',
54 'staff_searchable' => '1',
55 'description' => 'School ID Number',
56 'authorised_value_category' => '',
58 'code' => 'school_id',
62 'opac_display' => '1',
63 'staff_searchable' => '1',
64 'description' => 'Homeroom',
65 'authorised_value_category' => '',
70 }; # This is important to prevent extended_attributes_merge from touching DB.
76 line1
=> "homeroom:501",
78 merge
=> "homeroom:501,grade:01",
81 line1
=> "homeroom:224,grade:04,deanslist:2008,deanslist:2007,somedata:xxx",
82 line2
=> "homeroom:115,grade:05,deanslist:2009,extradata:foobar",
83 merge
=> "homeroom:115,grade:05,deanslist:2008,deanslist:2007,deanslist:2009,extradata:foobar,somedata:xxx",
87 can_ok
('C4::Members::Attributes', qw(extended_attributes_merge extended_attributes_code_value_arrayref));
89 ok
(ref($C4::Members
::Attributes
::AttributeTypes
) eq 'HASH', '$C4::Members::Attributes::AttributeTypes is a hashref');
91 foreach my $test (@merge_tests) {
92 my ($old, $new, $merged);
93 ok
($old = extended_attributes_code_value_arrayref
($test->{line1
}), "extended_attributes_code_value_arrayref('$test->{line1}')");
94 ok
($new = extended_attributes_code_value_arrayref
($test->{line2
}), "extended_attributes_code_value_arrayref('$test->{line2}')");
95 ok
($merged = extended_attributes_merge
($old, $new), "extended_attributes_merge(\$old, \$new)");
96 ok
($merged = extended_attributes_merge
($old, $new, 1), "extended_attributes_merge(\$old, \$new, 1)");