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

(-)a/Koha/Patron.pm (+4 lines)
Lines 311-316 sub store { Link Here
311
                    $self->guarantor_relationships->delete
311
                    $self->guarantor_relationships->delete
312
                      unless ( $self->category->can_be_guarantee );
312
                      unless ( $self->category->can_be_guarantee );
313
313
314
                    # Only these patron types can be guarantors,
315
                    # remove guarantee relationships otherwise
316
                    $self->guarantee_relationships->delete
317
                      unless $self->category->category_type =~ /A|I|S|X/;
314
                }
318
                }
315
319
316
                # Actionlogs
320
                # Actionlogs
(-)a/t/db_dependent/Patrons.t (-2 / +21 lines)
Lines 106-112 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 => 26;
109
    plan tests => 30;
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',
Lines 212-217 subtest "Update patron categories" => sub { Link Here
212
    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');
212
    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');
213
    is( Koha::Patrons->find($inst->borrowernumber)->guarantee_relationships->guarantees->count,0,'Guarantee was removed when made adult');
213
    is( Koha::Patrons->find($inst->borrowernumber)->guarantee_relationships->guarantees->count,0,'Guarantee was removed when made adult');
214
214
215
    my $adult4 = $builder->build_object({class => 'Koha::Patrons', value => {
216
            categorycode=>$a_categorycode,
217
            branchcode=>$branchcode2,
218
            dateenrolled=>'2017-01-01',
219
        }
220
    });
221
    my $child4 = $builder->build_object({class => 'Koha::Patrons', value => {
222
            dateofbirth => dt_from_string->add(years=>-18),
223
            categorycode=>$c_categorycode,
224
            branchcode=>$branchcode1,
225
        }
226
    });
227
    $child4->add_guarantor({guarantor_id => $adult4->borrowernumber, relationship => 'test'});
228
229
    is( $adult4->guarantee_relationships->count, 1, "Adult has guarantee relationship" );
230
    is( $child4->guarantor_relationships->count, 1, "Child has guarantor relationship" );
231
    $adult4->categorycode($c_categorycode);
232
    $adult4->store();
233
    is( $adult4->guarantee_relationships->count, 0, "Adult turned child now has no guarantee relationship" );
234
    is( $child4->guarantor_relationships->count, 0, "Child of adult now turned child has no guarantor relationship" );
215
};
235
};
216
236
217
237
218
- 

Return to bug 30344