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

(-)a/Koha/Patron.pm (+4 lines)
Lines 305-310 sub store { Link Here
305
                      if ( $self->category->category_type ne 'C'
305
                      if ( $self->category->category_type ne 'C'
306
                        && $self->category->category_type ne 'P' );
306
                        && $self->category->category_type ne 'P' );
307
307
308
                    # Only these patron types can be guarantors,
309
                    # remove guarantee relationships otherwise
310
                    $self->guarantee_relationships->delete
311
                      unless $self->category->category_type =~ /A|I|S|X/;
308
                }
312
                }
309
313
310
                # Actionlogs
314
                # 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 => 24;
109
    plan tests => 28;
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 207-212 subtest "Update patron categories" => sub { Link Here
207
    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');
207
    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');
208
    is( Koha::Patrons->find($inst->borrowernumber)->guarantee_relationships->guarantees->count,0,'Guarantee was removed when made adult');
208
    is( Koha::Patrons->find($inst->borrowernumber)->guarantee_relationships->guarantees->count,0,'Guarantee was removed when made adult');
209
209
210
    my $adult4 = $builder->build_object({class => 'Koha::Patrons', value => {
211
            categorycode=>$a_categorycode,
212
            branchcode=>$branchcode2,
213
            dateenrolled=>'2017-01-01',
214
        }
215
    });
216
    my $child4 = $builder->build_object({class => 'Koha::Patrons', value => {
217
            dateofbirth => dt_from_string->add(years=>-18),
218
            categorycode=>$c_categorycode,
219
            branchcode=>$branchcode1,
220
        }
221
    });
222
    $child4->add_guarantor({guarantor_id => $adult4->borrowernumber, relationship => 'test'});
223
224
    is( $adult4->guarantee_relationships->count, 1, "Adult has guarantee relationship" );
225
    is( $child4->guarantor_relationships->count, 1, "Child has guarantor relationship" );
226
    $adult4->categorycode($c_categorycode);
227
    $adult4->store();
228
    is( $adult4->guarantee_relationships->count, 0, "Adult turned child now has no guarantee relationship" );
229
    is( $child4->guarantor_relationships->count, 0, "Child of adult now turned child has no guarantor relationship" );
210
};
230
};
211
231
212
232
213
- 

Return to bug 30344