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 'password_allowed' => '0',
21 'authorised_value_category' => '',
27 'opac_display' => '0',
28 'staff_searchable' => '1',
29 'description' => 'Deans List (annual)',
30 'password_allowed' => '0',
31 'authorised_value_category' => '',
33 'code' => 'deanslist',
37 'opac_display' => '0',
38 'staff_searchable' => '0',
39 'description' => 'Some Ext. Attribute',
40 'password_allowed' => '0',
41 'authorised_value_category' => '',
47 'opac_display' => '0',
48 'staff_searchable' => '0',
49 'description' => 'Another Ext. Attribute',
50 'password_allowed' => '0',
51 'authorised_value_category' => '',
53 'code' => 'extradata',
57 'opac_display' => '1',
58 'staff_searchable' => '1',
59 'description' => 'School ID Number',
60 'password_allowed' => '0',
61 'authorised_value_category' => '',
63 'code' => 'school_id',
67 'opac_display' => '1',
68 'staff_searchable' => '1',
69 'description' => 'Homeroom',
70 'password_allowed' => '0',
71 'authorised_value_category' => '',
76 }; # This is important to prevent extended_attributes_merge from touching DB.
82 line1
=> "homeroom:501",
84 merge
=> "homeroom:501,grade:01",
87 line1
=> "homeroom:224,grade:04,deanslist:2008,deanslist:2007,somedata:xxx",
88 line2
=> "homeroom:115,grade:05,deanslist:2009,extradata:foobar",
89 merge
=> "homeroom:115,grade:05,deanslist:2008,deanslist:2007,deanslist:2009,extradata:foobar,somedata:xxx",
93 can_ok
('C4::Members::Attributes', qw(extended_attributes_merge extended_attributes_code_value_arrayref));
95 ok
(ref($C4::Members
::Attributes
::AttributeTypes
) eq 'HASH', '$C4::Members::Attributes::AttributeTypes is a hashref');
97 foreach my $test (@merge_tests) {
98 my ($old, $new, $merged);
99 ok
($old = extended_attributes_code_value_arrayref
($test->{line1
}), "extended_attributes_code_value_arrayref('$test->{line1}')");
100 ok
($new = extended_attributes_code_value_arrayref
($test->{line2
}), "extended_attributes_code_value_arrayref('$test->{line2}')");
101 ok
($merged = extended_attributes_merge
($old, $new), "extended_attributes_merge(\$old, \$new)");
102 ok
($merged = extended_attributes_merge
($old, $new, 1), "extended_attributes_merge(\$old, \$new, 1)");