Bug 11889: (QA follow-up) Fix tests

We need some changes for 28959 changing category to public.
Added the userenv mocking.

Note: A follow-up does a bit more refactoring here. But they
should pass at least now.

Test plan:
Run t/db_dependent/Virtualshelves.t
Run t/db_dependent/Koha/Patrons.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2022-06-08 14:35:31 +00:00 committed by Tomas Cohen Arazi
parent 2eac11c24d
commit 1d1432cfb5
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 13 additions and 10 deletions

View File

@ -463,10 +463,13 @@ subtest "delete" => sub {
plan tests => 11;
t::lib::Mocks::mock_preference( 'BorrowersLog', 1 );
t::lib::Mocks::mock_preference( 'ListOwnershipUponPatronDeletion', 'transfer' );
Koha::Virtualshelves->search({})->delete;
my $userenv = C4::Context->userenv();
Koha::Virtualshelves->delete;
my $staff_patron = $builder->build_object({ class => 'Koha::Patrons' });
t::lib::Mocks::mock_userenv({ patron => $staff_patron });
my $patron = $builder->build( { source => 'Borrower' } );
my $patron_for_sharing = (ref($userenv) eq 'HASH' ) ? $userenv->{'number'} : 0;
my $patron_for_sharing = $staff_patron->borrowernumber;
my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} );
my $hold = $builder->build(
{ source => 'Reserve',
@ -477,19 +480,19 @@ subtest "delete" => sub {
my $private_list = Koha::Virtualshelf->new({
shelfname => "private",
owner => $patron->{borrowernumber},
category => 1
public => 0,
}
)->store;
my $public_list = Koha::Virtualshelf->new({
shelfname => "public",
owner => $patron->{borrowernumber},
category => 2
public => 1,
}
)->store;
my $list_to_share = Koha::Virtualshelf->new({
shelfname => "shared",
owner => $patron->{borrowernumber},
category => 1
public => 0,
}
)->store;
@ -520,19 +523,19 @@ subtest "delete" => sub {
my $private_list2 = Koha::Virtualshelf->new({
shelfname => "private",
owner => $patron2->{borrowernumber},
category => 1
public => 0,
}
)->store;
my $public_list2 = Koha::Virtualshelf->new({
shelfname => "public",
owner => $patron2->{borrowernumber},
category => 2
public => 1,
}
)->store;
my $list_to_share2 = Koha::Virtualshelf->new({
shelfname => "shared",
owner => $patron2->{borrowernumber},
category => 1
public => 0,
}
)->store;

View File

@ -480,7 +480,7 @@ subtest 'Get shelves' => sub {
my $shelf_to_share = Koha::Virtualshelf->new({
shelfname => "shared shelf",
owner => $patron1->{borrowernumber},
category => 1,
public => 0,
}
)->store;