View | Details | Raw Unified | Return to bug 26307
Collapse All | Expand All

(-)a/t/db_dependent/Patrons.t (-4 / +13 lines)
Lines 147-159 subtest "Update patron categories" => sub { Link Here
147
        }
147
        }
148
    });
148
    });
149
    $prof->add_guarantor({guarantor_id => $inst->borrowernumber, relationship => 'test'});
149
    $prof->add_guarantor({guarantor_id => $inst->borrowernumber, relationship => 'test'});
150
    # Child beeing 4 years 11 months old => should be under age
150
    my $child1 = $builder->build_object({class => 'Koha::Patrons', value => {
151
    my $child1 = $builder->build_object({class => 'Koha::Patrons', value => {
151
            dateofbirth => dt_from_string->add(years=>-4),
152
            dateofbirth => dt_from_string->add( years => -5, days => 1 ),
152
            categorycode=>$c_categorycode,
153
            categorycode=>$c_categorycode,
153
            branchcode=>$branchcode1,
154
            branchcode=>$branchcode1,
154
        }
155
        }
155
    });
156
    });
156
    $child1->add_guarantor({guarantor_id => $adult1->borrowernumber, relationship => 'test'});
157
    $child1->add_guarantor({guarantor_id => $adult1->borrowernumber, relationship => 'test'});
158
    # Patron beeing exactly 5 years old => should not be under age
159
    my $child1bis = $builder->build_object({class => 'Koha::Patrons', value => {
160
            dateofbirth => dt_from_string->add( years => -5 ),
161
            categorycode=>$c_categorycode,
162
            branchcode=>$branchcode1,
163
        }
164
    });
157
    my $child2 = $builder->build_object({class => 'Koha::Patrons', value => {
165
    my $child2 = $builder->build_object({class => 'Koha::Patrons', value => {
158
            dateofbirth => dt_from_string->add(years=>-8),
166
            dateofbirth => dt_from_string->add(years=>-8),
159
            categorycode=>$c_categorycode,
167
            categorycode=>$c_categorycode,
Lines 161-166 subtest "Update patron categories" => sub { Link Here
161
        }
169
        }
162
    });
170
    });
163
    $child2->add_guarantor({guarantor_id => $adult1->borrowernumber, relationship => 'test'});
171
    $child2->add_guarantor({guarantor_id => $adult1->borrowernumber, relationship => 'test'});
172
    # Patron beeing 17 years 11 months old => should not be over age
164
    my $child3 = $builder->build_object({class => 'Koha::Patrons', value => {
173
    my $child3 = $builder->build_object({class => 'Koha::Patrons', value => {
165
            dateofbirth => dt_from_string->add( years => -18, days => 1 ),
174
            dateofbirth => dt_from_string->add( years => -18, days => 1 ),
166
            categorycode=>$c_categorycode,
175
            categorycode=>$c_categorycode,
Lines 168-173 subtest "Update patron categories" => sub { Link Here
168
        }
177
        }
169
    });
178
    });
170
    $child3->add_guarantor({guarantor_id => $adult1->borrowernumber, relationship => 'test'});
179
    $child3->add_guarantor({guarantor_id => $adult1->borrowernumber, relationship => 'test'});
180
    # Patron beeing exactly 18 years old => should be over age
171
    my $child4 = $builder->build_object({class => 'Koha::Patrons', value => {
181
    my $child4 = $builder->build_object({class => 'Koha::Patrons', value => {
172
            surname => 'child4',
182
            surname => 'child4',
173
            dateofbirth => dt_from_string->add( years => -18 ),
183
            dateofbirth => dt_from_string->add( years => -18 ),
Lines 178-184 subtest "Update patron categories" => sub { Link Here
178
    $builder->build({source=>'Accountline',value => {amountoutstanding=>4.99,borrowernumber=>$adult1->borrowernumber}});
188
    $builder->build({source=>'Accountline',value => {amountoutstanding=>4.99,borrowernumber=>$adult1->borrowernumber}});
179
    $builder->build({source=>'Accountline',value => {amountoutstanding=>5.01,borrowernumber=>$adult2->borrowernumber}});
189
    $builder->build({source=>'Accountline',value => {amountoutstanding=>5.01,borrowernumber=>$adult2->borrowernumber}});
180
190
181
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode})->count,4,'Four patrons in child category');
191
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode})->count,5,'Five patrons in child category');
182
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode,too_young=>1})->count,1,'One under age patron in child category');
192
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode,too_young=>1})->count,1,'One under age patron in child category');
183
    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');
193
    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');
184
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode,too_old=>1})->count,1,'One over age patron in child category');
194
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode,too_old=>1})->count,1,'One over age patron in child category');
Lines 198-204 subtest "Update patron categories" => sub { Link Here
198
    is( Koha::Patrons->search_patrons_to_update_category({from=>$a_categorycode,fine_max=>5})->count,2,'Two patrons with fines under $5, patron with no fine history is found');
208
    is( Koha::Patrons->search_patrons_to_update_category({from=>$a_categorycode,fine_max=>5})->count,2,'Two patrons with fines under $5, patron with no fine history is found');
199
209
200
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,3,'Guarantor has 3 guarantees');
210
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,3,'Guarantor has 3 guarantees');
201
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode})->update_category_to({category=>$c_categorycode_2}),4,'Four child patrons updated to another child category with no params passed');
211
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode})->update_category_to({category=>$c_categorycode_2}),5,'Five child patrons updated to another child category with no params passed');
202
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,3,'Guarantees not removed when made changing child categories');
212
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,3,'Guarantees not removed when made changing child categories');
203
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode_2,too_young=>1})->update_category_to({category=>$a_categorycode}),1,'One child patron updated to adult category');
213
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode_2,too_young=>1})->update_category_to({category=>$a_categorycode}),1,'One child patron updated to adult category');
204
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,2,'Guarantee was removed when made adult');
214
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,2,'Guarantee was removed when made adult');
205
- 

Return to bug 26307