From 2527d93cb58cb3627637ddaa27d77598259e9119 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Fri, 30 Jun 2023 15:35:47 +0300 Subject: [PATCH] Bug 32340: Fix t/db_dependent/Reserves.t tests This patch does following fixes: - Get rid of "Use of uninitialized value $email in string ne" warning by adding email for test patrons - Prevent "Can't call method "can_edit_items_from" on an undefined value" by adding mock manager patron - Fix typos in DefaultHoldExpirationdate tests To test: 1) Run prove t/db_dependent/Reserves.t. -> Tests should fail. 2) Apply this patch. 3) Rerun prove t/db_dependent/Reserves.t. -> Success! Sponsored-by: Koha-Suomi Oy --- t/db_dependent/Reserves.t | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 2d97fa43a1..5270b52629 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -81,7 +81,8 @@ my $category_2 = $builder->build({ source => 'Category' })->{ categorycode }; my $itemtype = $builder->build( { source => 'Itemtype', value => { notforloan => undef } } )->{itemtype}; -t::lib::Mocks::mock_userenv({ branchcode => $branch_1 }); +my $manager = $builder->build_object({class => 'Koha::Patrons', value => {branchcode => $branch_1} }); +t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $branch_1 }); my $bibnum = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber; @@ -153,23 +154,27 @@ $requesters{$branch_1} = Koha::Patron->new({ branchcode => $branch_1, categorycode => $category_2, surname => "borrower from $branch_1", + email => "totallyvalid\@email", })->store->borrowernumber; for my $i ( 2 .. 5 ) { $requesters{"CPL$i"} = Koha::Patron->new({ branchcode => $branch_1, categorycode => $category_2, surname => "borrower $i from $branch_1", + email => "totallyvalid\@email", })->store->borrowernumber; } $requesters{$branch_2} = Koha::Patron->new({ branchcode => $branch_2, categorycode => $category_2, surname => "borrower from $branch_2", + email => "totallyvalid\@email", })->store->borrowernumber; $requesters{$branch_3} = Koha::Patron->new({ branchcode => $branch_3, categorycode => $category_2, surname => "borrower from $branch_3", + email => "totallyvalid\@email", })->store->borrowernumber; # Configure rules so that $branch_1 allows only $branch_1 patrons @@ -1733,13 +1738,13 @@ subtest 'CanItemBeReserved() tests' => sub { $schema->storage->txn_rollback; }; -subtest 'DefaultHoldExpiration tests' => sub { +subtest 'DefaultHoldExpirationdate tests' => sub { plan tests => 2; $schema->storage->txn_begin; t::lib::Mocks::mock_preference( 'DefaultHoldExpirationdate', 1 ); t::lib::Mocks::mock_preference( 'DefaultHoldExpirationdatePeriod', 365 ); - t::lib::Mocks::mock_preference( 'DefaultHoldExpirationUnitOfTime', 'days;' ); + t::lib::Mocks::mock_preference( 'DefaultHoldExpirationdateUnitOfTime', 'days' ); my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); my $item = $builder->build_sample_item(); -- 2.34.1