Lines 105-114
foreach my $b ( $patrons->as_list() ) {
Link Here
|
105 |
} |
105 |
} |
106 |
|
106 |
|
107 |
subtest "Update patron categories" => sub { |
107 |
subtest "Update patron categories" => sub { |
108 |
plan tests => 23; |
108 |
plan tests => 17; |
109 |
$builder->schema->resultset( 'Issue' )->delete_all; |
|
|
110 |
$builder->schema->resultset( 'Borrower' )->delete_all; |
111 |
$builder->schema->resultset( 'Category' )->delete_all; |
112 |
my $c_categorycode = $builder->build({ source => 'Category', value => { |
109 |
my $c_categorycode = $builder->build({ source => 'Category', value => { |
113 |
category_type=>'C', |
110 |
category_type=>'C', |
114 |
upperagelimit=>17, |
111 |
upperagelimit=>17, |
Lines 167-197
subtest "Update patron categories" => sub {
Link Here
|
167 |
$builder->build({source=>'Accountline',value => {amountoutstanding=>4.99,borrowernumber=>$adult1->{borrowernumber}}}); |
164 |
$builder->build({source=>'Accountline',value => {amountoutstanding=>4.99,borrowernumber=>$adult1->{borrowernumber}}}); |
168 |
$builder->build({source=>'Accountline',value => {amountoutstanding=>5.01,borrowernumber=>$adult2->{borrowernumber}}}); |
165 |
$builder->build({source=>'Accountline',value => {amountoutstanding=>5.01,borrowernumber=>$adult2->{borrowernumber}}}); |
169 |
|
166 |
|
170 |
is( Koha::Patrons->search_patrons_to_update({from=>$c_categorycode})->count,3,'Three patrons in child category'); |
167 |
is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode})->count,3,'Three patrons in child category'); |
171 |
is( Koha::Patrons->search_patrons_to_update({from=>$c_categorycode,ageunder=>1})->count,1,'One under age patron in child category'); |
168 |
is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode,too_young=>1})->count,1,'One under age patron in child category'); |
172 |
is( Koha::Patrons->search_patrons_to_update({from=>$c_categorycode,ageunder=>1})->next->borrowernumber,$child1->{borrowernumber},'Under age patron in child category is expected one'); |
169 |
is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode,too_young=>1})->next->borrowernumber,$child1->{borrowernumber},'Under age patron in child category is expected one'); |
173 |
is( Koha::Patrons->search_patrons_to_update({from=>$c_categorycode,ageover=>1})->count,1,'One over age patron in child category'); |
170 |
is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode,too_old=>1})->count,1,'One over age patron in child category'); |
174 |
is( Koha::Patrons->search_patrons_to_update({from=>$c_categorycode,ageover=>1})->next->borrowernumber,$child3->{borrowernumber},'Over age patron in child category is expected one'); |
171 |
is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode,too_old=>1})->next->borrowernumber,$child3->{borrowernumber},'Over age patron in child category is expected one'); |
175 |
is( Koha::Patrons->search_patrons_to_update({from=>$a_categorycode,search_params=>{branchcode=>$branchcode2}})->count,1,'One patron in branch 2'); |
172 |
is( Koha::Patrons->search({branchcode=>$branchcode2})->search_patrons_to_update_category({from=>$a_categorycode})->count,1,'One patron in branch 2'); |
176 |
is( Koha::Patrons->search_patrons_to_update({from=>$a_categorycode,search_params=>{branchcode=>$branchcode2}})->next->borrowernumber,$adult2->{borrowernumber},'Adult patron in branch 2 is expected one'); |
173 |
is( Koha::Patrons->search({branchcode=>$branchcode2})->search_patrons_to_update_category({from=>$a_categorycode})->next->borrowernumber,$adult2->{borrowernumber},'Adult patron in branch 2 is expected one'); |
177 |
is( Koha::Patrons->search_patrons_to_update({from=>$a_categorycode,fine_min=>5})->count,1,'One patron with fines over $5'); |
174 |
is( Koha::Patrons->search_patrons_to_update_category({from=>$a_categorycode,fine_min=>5})->count,1,'One patron with fines over $5'); |
178 |
is( Koha::Patrons->search_patrons_to_update({from=>$a_categorycode,fine_min=>5})->next->borrowernumber,$adult2->{borrowernumber},'One patron with fines over $5 is expected one'); |
175 |
is( Koha::Patrons->search_patrons_to_update_category({from=>$a_categorycode,fine_min=>5})->next->borrowernumber,$adult2->{borrowernumber},'One patron with fines over $5 is expected one'); |
179 |
is( Koha::Patrons->search_patrons_to_update({from=>$a_categorycode,fine_max=>5})->count,1,'One patron with fines under $5'); |
176 |
is( Koha::Patrons->search_patrons_to_update_category({from=>$a_categorycode,fine_max=>5})->count,1,'One patron with fines under $5'); |
180 |
is( Koha::Patrons->search_patrons_to_update({from=>$a_categorycode,fine_max=>5})->next->borrowernumber,$adult1->{borrowernumber},'One patron with fines under $5 is expected one'); |
177 |
is( Koha::Patrons->search_patrons_to_update_category({from=>$a_categorycode,fine_max=>5})->next->borrowernumber,$adult1->{borrowernumber},'One patron with fines under $5 is expected one'); |
181 |
|
|
|
182 |
is( Koha::Patrons->search_patrons_to_update({from=>$a_categorycode,search_params=>{dateenrolled=>{'<'=>'2018-01-01'}}})->count,1,'One adult patron enrolled before date'); |
183 |
is( Koha::Patrons->search_patrons_to_update({from=>$a_categorycode,search_params=>{dateenrolled=>{'<'=>'2018-01-01'}}})->next->borrowernumber,$adult2->{borrowernumber},'One adult patron enrolled before date is expected one'); |
184 |
is( Koha::Patrons->search_patrons_to_update({from=>$a_categorycode,search_params=>{dateenrolled=>{'>'=>'2017-01-01'}}})->count,1,'One adult patron enrolled after date'); |
185 |
is( Koha::Patrons->search_patrons_to_update({from=>$a_categorycode,search_params=>{dateenrolled=>{'>'=>'2017-01-01'}}})->next->borrowernumber,$adult1->{borrowernumber},'One adult patron enrolled after date is expected one'); |
186 |
is( Koha::Patrons->search_patrons_to_update({from=>$a_categorycode,search_params=>{'sort1'=>'quack'}})->count,1,'One adult patron has a quack'); |
187 |
is( Koha::Patrons->search_patrons_to_update({from=>$a_categorycode,search_params=>{'sort1'=>'quack'}})->next->borrowernumber,$adult1->{borrowernumber},'One adult patron with a quack is expected one'); |
188 |
|
178 |
|
189 |
is( Koha::Patrons->find($adult1->{borrowernumber})->guarantees->count,3,'Guarantor has 3 guarantees'); |
179 |
is( Koha::Patrons->find($adult1->{borrowernumber})->guarantees->count,3,'Guarantor has 3 guarantees'); |
190 |
is( Koha::Patrons->search_patrons_to_update({from=>$c_categorycode,ageunder=>1})->update_category({to=>$a_categorycode}),1,'One child patron updated to adult category'); |
180 |
is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode,too_young=>1})->update_category_to({category=>$a_categorycode}),1,'One child patron updated to adult category'); |
191 |
is( Koha::Patrons->find($adult1->{borrowernumber})->guarantees->count,2,'Guarantee was removed when made adult'); |
181 |
is( Koha::Patrons->find($adult1->{borrowernumber})->guarantees->count,2,'Guarantee was removed when made adult'); |
192 |
|
182 |
|
193 |
is( Koha::Patrons->find($inst->{borrowernumber})->guarantees->count,1,'Guarantor has 1 guarantees'); |
183 |
is( Koha::Patrons->find($inst->{borrowernumber})->guarantees->count,1,'Guarantor has 1 guarantees'); |
194 |
is( Koha::Patrons->search_patrons_to_update({from=>$p_categorycode})->update_category({to=>$a_categorycode}),1,'One professional patron updated to adult category'); |
184 |
is( Koha::Patrons->search_patrons_to_update_category({from=>$p_categorycode})->update_category_to({category=>$a_categorycode}),1,'One professional patron updated to adult category'); |
195 |
is( Koha::Patrons->find($inst->{borrowernumber})->guarantees->count,0,'Guarantee was removed when made adult'); |
185 |
is( Koha::Patrons->find($inst->{borrowernumber})->guarantees->count,0,'Guarantee was removed when made adult'); |
196 |
|
186 |
|
197 |
}; |
187 |
}; |
198 |
- |
|
|