Bug 23493: Remove commented lines
[koha.git] / t / Members_Attributes.t
blob205d6117f1283d2f46f004369d184d2f5a373b2c
1 #!/usr/bin/perl
5 use strict;
6 use warnings;
8 use Test::More tests => 11;
10 BEGIN {
11 use_ok('C4::Members::Attributes', qw(:all));
14 INIT {
15 $C4::Members::Attributes::AttributeTypes = {
16 'grade' => {
17 'opac_display' => '1',
18 'staff_searchable' => '1',
19 'description' => 'Grade level',
20 'authorised_value_category' => '',
21 'repeatable' => '0',
22 'code' => 'grade',
23 'unique_id' => '0'
25 'deanslist' => {
26 'opac_display' => '0',
27 'staff_searchable' => '1',
28 'description' => 'Deans List (annual)',
29 'authorised_value_category' => '',
30 'repeatable' => '1',
31 'code' => 'deanslist',
32 'unique_id' => '0'
34 'somedata' => {
35 'opac_display' => '0',
36 'staff_searchable' => '0',
37 'description' => 'Some Ext. Attribute',
38 'authorised_value_category' => '',
39 'repeatable' => '0',
40 'code' => 'somedata',
41 'unique_id' => '0'
43 'extradata' => {
44 'opac_display' => '0',
45 'staff_searchable' => '0',
46 'description' => 'Another Ext. Attribute',
47 'authorised_value_category' => '',
48 'repeatable' => '0',
49 'code' => 'extradata',
50 'unique_id' => '0'
52 'school_id' => {
53 'opac_display' => '1',
54 'staff_searchable' => '1',
55 'description' => 'School ID Number',
56 'authorised_value_category' => '',
57 'repeatable' => '0',
58 'code' => 'school_id',
59 'unique_id' => '1'
61 'homeroom' => {
62 'opac_display' => '1',
63 'staff_searchable' => '1',
64 'description' => 'Homeroom',
65 'authorised_value_category' => '',
66 'repeatable' => '0',
67 'code' => 'homeroom',
68 'unique_id' => '0'
70 }; # This is important to prevent extended_attributes_merge from touching DB.
74 my @merge_tests = (
76 line1 => "homeroom:501",
77 line2 => "grade:01",
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)");