Bug 31288: Regression tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Tomas Cohen Arazi 2022-08-03 11:40:51 -03:00
parent e92827b9bd
commit fa22219a1f
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 17 additions and 3 deletions

View File

@ -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 );