From 2758915e0a6c6bbca972616ce008ccbe8e4bfd43 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 8 Jun 2022 14:35:31 +0000 Subject: [PATCH] Bug 11889: (QA follow-up) Fix tests Content-Type: text/plain; charset=utf-8 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 --- t/db_dependent/Koha/Patrons.t | 21 ++++++++++++--------- t/db_dependent/Virtualshelves.t | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index a5fcad2430..aeb5ce17ab 100755 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -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; diff --git a/t/db_dependent/Virtualshelves.t b/t/db_dependent/Virtualshelves.t index 6c71456ad4..1de7ddc580 100755 --- a/t/db_dependent/Virtualshelves.t +++ b/t/db_dependent/Virtualshelves.t @@ -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; -- 2.20.1