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

(-)a/Koha/Patron.pm (-2 / +1 lines)
Lines 287-294 sub store { Link Here
287
287
288
                    # Clean up guarantors on category change if required
288
                    # Clean up guarantors on category change if required
289
                    $self->guarantor_relationships->delete
289
                    $self->guarantor_relationships->delete
290
                      if ( $self->category->category_type ne 'C'
290
                      unless ( $self->category->canbeguarantee );
291
                        && $self->category->category_type ne 'P' );
292
291
293
                }
292
                }
294
293
(-)a/t/db_dependent/Patrons.t (-3 / +7 lines)
Lines 106-124 foreach my $b ( $patrons->as_list() ) { Link Here
106
}
106
}
107
107
108
subtest "Update patron categories" => sub {
108
subtest "Update patron categories" => sub {
109
    plan tests => 19;
109
    plan tests => 21;
110
    t::lib::Mocks::mock_preference( 'borrowerRelationship', 'test' );
110
    t::lib::Mocks::mock_preference( 'borrowerRelationship', 'test' );
111
    my $c_categorycode = $builder->build({ source => 'Category', value => {
111
    my $c_categorycode = $builder->build({ source => 'Category', value => {
112
            category_type=>'C',
112
            category_type=>'C',
113
            upperagelimit=>17,
113
            upperagelimit=>17,
114
            dateofbirthrequired=>5,
114
            dateofbirthrequired=>5,
115
            canbeguarantee=>1,
115
        } })->{categorycode};
116
        } })->{categorycode};
116
    my $c_categorycode_2 = $builder->build({ source => 'Category', value => {
117
    my $c_categorycode_2 = $builder->build({ source => 'Category', value => {
117
            category_type=>'C',
118
            category_type=>'C',
118
            upperagelimit=>17,
119
            upperagelimit=>17,
119
            dateofbirthrequired=>5,
120
            dateofbirthrequired=>5,
121
            canbeguarantee=>1,
120
        } })->{categorycode};
122
        } })->{categorycode};
121
    my $a_categorycode = $builder->build({ source => 'Category', value => {category_type=>'A'} })->{categorycode};
123
    my $a_categorycode = $builder->build({ source => 'Category', value => {category_type=>'A', canbeguarantee=>0} })->{categorycode};
124
    my $a_categorycode_2 = $builder->build({ source => 'Category', value => {category_type=>'A', canbeguarantee=>1} })->{categorycode};
122
    my $p_categorycode = $builder->build({ source => 'Category', value => {category_type=>'P'} })->{categorycode};
125
    my $p_categorycode = $builder->build({ source => 'Category', value => {category_type=>'P'} })->{categorycode};
123
    my $i_categorycode = $builder->build({ source => 'Category', value => {category_type=>'I'} })->{categorycode};
126
    my $i_categorycode = $builder->build({ source => 'Category', value => {category_type=>'I'} })->{categorycode};
124
    my $branchcode1 = $builder->build({ source => 'Branch' })->{branchcode};
127
    my $branchcode1 = $builder->build({ source => 'Branch' })->{branchcode};
Lines 188-193 subtest "Update patron categories" => sub { Link Here
188
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,3,'Guarantees not removed when made changing child categories');
191
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,3,'Guarantees not removed when made changing child categories');
189
    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');
192
    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');
190
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,2,'Guarantee was removed when made adult');
193
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,2,'Guarantee was removed when made adult');
194
    is( Koha::Patrons->search_patrons_to_update_category({from=>$c_categorycode_2})->update_category_to({category=>$a_categorycode_2}),2,'Two child patrons updated to adult category');
195
    is( Koha::Patrons->find($adult1->borrowernumber)->guarantee_relationships->guarantees->count,2,'Guarantees were not removed when made adult which can be guarantee');
191
196
192
    is( Koha::Patrons->find($inst->borrowernumber)->guarantee_relationships->guarantees->count,1,'Guarantor has 1 guarantees');
197
    is( Koha::Patrons->find($inst->borrowernumber)->guarantee_relationships->guarantees->count,1,'Guarantor has 1 guarantees');
193
    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');
198
    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');
194
- 

Return to bug 12446