Lines 81-87
subtest 'library' => sub {
Link Here
|
81 |
}; |
81 |
}; |
82 |
|
82 |
|
83 |
subtest 'guarantees' => sub { |
83 |
subtest 'guarantees' => sub { |
84 |
plan tests => 8; |
84 |
plan tests => 13; |
85 |
my $guarantees = $new_patron_1->guarantees; |
85 |
my $guarantees = $new_patron_1->guarantees; |
86 |
is( ref($guarantees), 'Koha::Patrons', 'Koha::Patron->guarantees should return a Koha::Patrons result set in a scalar context' ); |
86 |
is( ref($guarantees), 'Koha::Patrons', 'Koha::Patron->guarantees should return a Koha::Patrons result set in a scalar context' ); |
87 |
is( $guarantees->count, 0, 'new_patron_1 should have 0 guarantee' ); |
87 |
is( $guarantees->count, 0, 'new_patron_1 should have 0 guarantee' ); |
Lines 99-104
subtest 'guarantees' => sub {
Link Here
|
99 |
is( ref(\@guarantees), 'ARRAY', 'Koha::Patron->guarantees should return an array in a list context' ); |
99 |
is( ref(\@guarantees), 'ARRAY', 'Koha::Patron->guarantees should return an array in a list context' ); |
100 |
is( scalar(@guarantees), 2, 'new_patron_1 should have 2 guarantees' ); |
100 |
is( scalar(@guarantees), 2, 'new_patron_1 should have 2 guarantees' ); |
101 |
$_->delete for @guarantees; |
101 |
$_->delete for @guarantees; |
|
|
102 |
|
103 |
#Test return order of guarantees BZ 18635 |
104 |
my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; |
105 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
106 |
|
107 |
my $guarantor = $builder->build_object( { class => 'Koha::Patrons' } ); |
108 |
|
109 |
my $order_guarantee1 = $builder->build_object( { class => 'Koha::Patrons' , value => { |
110 |
surname => 'Zebra', |
111 |
guarantorid => $guarantor->borrowernumber |
112 |
} |
113 |
})->borrowernumber; |
114 |
|
115 |
my $order_guarantee2 = $builder->build_object( { class => 'Koha::Patrons' , value => { |
116 |
surname => 'Yak', |
117 |
guarantorid => $guarantor->borrowernumber |
118 |
} |
119 |
})->borrowernumber; |
120 |
|
121 |
my $order_guarantee3 = $builder->build_object( { class => 'Koha::Patrons' , value => { |
122 |
surname => 'Xerus', |
123 |
firstname => 'Walrus', |
124 |
guarantorid => $guarantor->borrowernumber |
125 |
} |
126 |
})->borrowernumber; |
127 |
|
128 |
my $order_guarantee4 = $builder->build_object( { class => 'Koha::Patrons' , value => { |
129 |
surname => 'Xerus', |
130 |
firstname => 'Vulture', |
131 |
guarantorid => $guarantor->borrowernumber |
132 |
} |
133 |
})->borrowernumber; |
134 |
|
135 |
my $order_guarantee5 = $builder->build_object( { class => 'Koha::Patrons' , value => { |
136 |
surname => 'Xerus', |
137 |
firstname => 'Unicorn', |
138 |
guarantorid => $guarantor->borrowernumber |
139 |
} |
140 |
})->borrowernumber; |
141 |
|
142 |
$guarantees = $guarantor->guarantees(); |
143 |
|
144 |
is( $guarantees->next()->borrowernumber, $order_guarantee5, "Return first guarantor alphabetically" ); |
145 |
is( $guarantees->next()->borrowernumber, $order_guarantee4, "Return second guarantor alphabetically" ); |
146 |
is( $guarantees->next()->borrowernumber, $order_guarantee3, "Return third guarantor alphabetically" ); |
147 |
is( $guarantees->next()->borrowernumber, $order_guarantee2, "Return fourth guarantor alphabetically" ); |
148 |
is( $guarantees->next()->borrowernumber, $order_guarantee1, "Return fifth guarantor alphabetically" ); |
102 |
}; |
149 |
}; |
103 |
|
150 |
|
104 |
subtest 'category' => sub { |
151 |
subtest 'category' => sub { |
Lines 993-998
subtest 'libraries_where_can_see_patrons + can_see_patron_infos + search_limited
Link Here
|
993 |
# + library_12 |
1040 |
# + library_12 |
994 |
# group2 |
1041 |
# group2 |
995 |
# + library21 |
1042 |
# + library21 |
|
|
1043 |
$nb_of_patrons = Koha::Patrons->search->count; |
996 |
my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1', ft_hide_patron_info => 1 } )->store; |
1044 |
my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1', ft_hide_patron_info => 1 } )->store; |
997 |
my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2', ft_hide_patron_info => 1 } )->store; |
1045 |
my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2', ft_hide_patron_info => 1 } )->store; |
998 |
my $library_11 = $builder->build( { source => 'Branch' } ); |
1046 |
my $library_11 = $builder->build( { source => 'Branch' } ); |
Lines 1063-1070
subtest 'libraries_where_can_see_patrons + can_see_patron_infos + search_limited
Link Here
|
1063 |
plan tests => 6; |
1111 |
plan tests => 6; |
1064 |
|
1112 |
|
1065 |
set_logged_in_user( $patron_11_1 ); |
1113 |
set_logged_in_user( $patron_11_1 ); |
1066 |
my $total_number_of_patrons = $nb_of_patrons + 6; # 2 created before + 4 for these subtests |
1114 |
my $total_number_of_patrons = $nb_of_patrons + 4; #we added four in these tests |
1067 |
is( Koha::Patrons->search->count, $total_number_of_patrons, 'Non-limited search should return all patrons'); |
1115 |
is( Koha::Patrons->search->count, $total_number_of_patrons, 'Non-limited search should return all patrons' ); |
1068 |
is( Koha::Patrons->search_limited->count, $total_number_of_patrons, 'patron_11_1 is allowed to see all patrons' ); |
1116 |
is( Koha::Patrons->search_limited->count, $total_number_of_patrons, 'patron_11_1 is allowed to see all patrons' ); |
1069 |
|
1117 |
|
1070 |
set_logged_in_user( $patron_11_2 ); |
1118 |
set_logged_in_user( $patron_11_2 ); |
Lines 1356-1364
subtest 'generate_userid' => sub {
Link Here
|
1356 |
$patron_2->delete; |
1404 |
$patron_2->delete; |
1357 |
}; |
1405 |
}; |
1358 |
|
1406 |
|
1359 |
|
1407 |
$nb_of_patrons = Koha::Patrons->search->count; |
1360 |
$retrieved_patron_1->delete; |
1408 |
$retrieved_patron_1->delete; |
1361 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
1409 |
is( Koha::Patrons->search->count, $nb_of_patrons - 1, 'Delete should have deleted the patron' ); |
1362 |
|
1410 |
|
1363 |
subtest 'Log cardnumber change' => sub { |
1411 |
subtest 'Log cardnumber change' => sub { |
1364 |
plan tests => 3; |
1412 |
plan tests => 3; |
1365 |
- |
|
|