Lines 460-468
subtest "move_to_deleted" => sub {
Link Here
|
460 |
}; |
460 |
}; |
461 |
|
461 |
|
462 |
subtest "delete" => sub { |
462 |
subtest "delete" => sub { |
463 |
plan tests => 13; |
463 |
plan tests => 16; |
464 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); |
464 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); |
465 |
t::lib::Mocks::mock_preference( 'ListOwnershipUponPatronDeletion', 'transfer' ); |
465 |
t::lib::Mocks::mock_preference( 'ListOwnershipUponPatronDeletion', 'transfer' ); |
|
|
466 |
t::lib::Mocks::mock_preference( 'ListOwnerDesignated', undef ); |
466 |
Koha::Virtualshelves->delete; |
467 |
Koha::Virtualshelves->delete; |
467 |
|
468 |
|
468 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
469 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
Lines 511-516
subtest "delete" => sub {
Link Here
|
511 |
my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'DELETE', object => $patron->borrowernumber } )->count; |
512 |
my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'DELETE', object => $patron->borrowernumber } )->count; |
512 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' ); |
513 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' ); |
513 |
|
514 |
|
|
|
515 |
# Test deletion with designated fallback owner |
516 |
my $designated_owner = $builder->build_object({ class => 'Koha::Patrons' }); |
517 |
t::lib::Mocks::mock_preference( 'ListOwnerDesignated', $designated_owner->id ); |
518 |
$patron = $builder->build_object({ class => 'Koha::Patrons' }); |
519 |
$private_list = Koha::Virtualshelf->new({ shelfname => "PR1", owner => $patron->id })->store; |
520 |
$public_list = Koha::Virtualshelf->new({ shelfname => "PU1", public => 1, owner => $patron->id })->store; |
521 |
$list_to_share = Koha::Virtualshelf->new({ shelfname => "SH1", owner => $patron->id })->store; |
522 |
$list_to_share->share("valid key")->accept( "valid key", $patron_for_sharing->id ); |
523 |
$patron->delete; |
524 |
is( Koha::Virtualshelves->find( $private_list->id ), undef, 'Private list gone' ); |
525 |
is( $public_list->discard_changes->get_column('owner'), $designated_owner->id, 'Public list transferred' ); |
526 |
is( $list_to_share->discard_changes->get_column('owner'), $designated_owner->id, 'Shared list transferred' ); |
527 |
|
528 |
# Finally test deleting lists |
514 |
t::lib::Mocks::mock_preference( 'ListOwnershipUponPatronDeletion', 'delete' ); |
529 |
t::lib::Mocks::mock_preference( 'ListOwnershipUponPatronDeletion', 'delete' ); |
515 |
Koha::Virtualshelves->delete; |
530 |
Koha::Virtualshelves->delete; |
516 |
my $patron2 = $builder->build_object({ class => 'Koha::Patrons' }); |
531 |
my $patron2 = $builder->build_object({ class => 'Koha::Patrons' }); |
517 |
- |
|
|