From fa22219a1fcc253df64842e52ccdd4b3f28b3a03 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 3 Aug 2022 11:40:51 -0300 Subject: [PATCH] Bug 31288: Regression tests Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Koha/Virtualshelves.t | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Koha/Virtualshelves.t b/t/db_dependent/Koha/Virtualshelves.t index 9b39ebd5ae..20d2454c99 100755 --- a/t/db_dependent/Koha/Virtualshelves.t +++ b/t/db_dependent/Koha/Virtualshelves.t @@ -94,7 +94,7 @@ subtest 'disown_or_delete() tests' => sub { subtest 'Fallback to userenv' => sub { - plan tests => 6; + plan tests => 7; $schema->storage->txn_begin; @@ -133,14 +133,28 @@ subtest 'disown_or_delete() tests' => sub { t::lib::Mocks::mock_preference( 'ListOwnershipUponPatronDeletion', 'transfer' ); t::lib::Mocks::mock_preference( 'ListOwnerDesignated', undef ); - t::lib::Mocks::mock_userenv({ patron => $patron_3 }); - my $rs = Koha::Virtualshelves->search( { shelfnumber => [ $public_list->id, $private_list->id, $private_list_shared->id ] } ); + my $public_list_to_delete = $builder->build_object( + { + class => "Koha::Virtualshelves", + value => { owner => $patron_1->id, public => 1 } + } + ); + my $rs = Koha::Virtualshelves->search({ shelfnumber => $public_list_to_delete->id }); my $result = $rs->disown_or_delete; is( ref($result), 'Koha::Virtualshelves', 'Return type is correct' ); $rs->reset; + is( $rs->count, 0, 'ListOwnerDesignated and userenv not set yield deletion' ); + + t::lib::Mocks::mock_userenv({ patron => $patron_3 }); + + $rs = Koha::Virtualshelves->search( { shelfnumber => [ $public_list->id, $private_list->id, $private_list_shared->id ] } ); + + $rs->disown_or_delete; + $rs->reset; + is( $rs->count, 2, 'The private/non-shared list was deleted' ); my $first = $rs->next; is( $first->id, $public_list->id ); -- 2.39.2