From e5f01894436efbe5d744e3a4abe1704109dcfb72 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Fri, 15 Nov 2024 11:19:12 +0000 Subject: [PATCH] Bug 33641: (Follow-up) Fix unit tests --- t/db_dependent/Circulation/Branch.t | 2 ++ t/db_dependent/Circulation/StoreLastBorrower.t | 7 +++++-- t/db_dependent/Koha/Account/Line.t | 3 +-- t/db_dependent/Koha/Checkouts.t | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/Circulation/Branch.t b/t/db_dependent/Circulation/Branch.t index 53e26d2d6a5..80a8cc61427 100755 --- a/t/db_dependent/Circulation/Branch.t +++ b/t/db_dependent/Circulation/Branch.t @@ -292,6 +292,8 @@ $query = $dbh->do( $query, {}, $borrower_id1, $item_id1, $samplebranch1->{branchcode} ); t::lib::Mocks::mock_preference( 'CataloguingLog', 1 ); +t::lib::Mocks::mock_userenv( { branchcode => $samplebranch2->{branchcode} } ); + my $log_count_before = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); my ($doreturn, $messages, $iteminformation, $borrower) = AddReturn('barcode_1', $samplebranch2->{branchcode}); diff --git a/t/db_dependent/Circulation/StoreLastBorrower.t b/t/db_dependent/Circulation/StoreLastBorrower.t index c3121bb954d..c4c7f37a225 100755 --- a/t/db_dependent/Circulation/StoreLastBorrower.t +++ b/t/db_dependent/Circulation/StoreLastBorrower.t @@ -38,10 +38,11 @@ subtest 'Test StoreLastBorrower' => sub { t::lib::Mocks::mock_preference( 'StoreLastBorrower', '1' ); - my $patron = $builder->build( + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $patron = $builder->build( { source => 'Borrower', - value => { privacy => 1, } + value => { privacy => 1, branchcode => $library->branchcode } } ); @@ -57,6 +58,8 @@ subtest 'Test StoreLastBorrower' => sub { } ); + t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); + $item = $item->get_from_storage; my $patron_object = $item->last_returned_by(); is( $patron_object, undef, 'Koha::Item::last_returned_by returned undef' ); diff --git a/t/db_dependent/Koha/Account/Line.t b/t/db_dependent/Koha/Account/Line.t index 229bae28d4b..20c9e64afa9 100755 --- a/t/db_dependent/Koha/Account/Line.t +++ b/t/db_dependent/Koha/Account/Line.t @@ -394,6 +394,7 @@ subtest 'apply() tests' => sub { is( $messages[0]->payload->{success}, 1, "'success' key in payload" ); t::lib::Mocks::mock_preference( 'MarkLostItemsAsReturned', 'onpayment'); + t::lib::Mocks::mock_userenv( { branchcode => $library->id } ); my $loser = $builder->build_object( { class => 'Koha::Patrons' } ); my $loser_account = $loser->account; @@ -443,8 +444,6 @@ subtest 'apply() tests' => sub { is( $loser->checkouts->next, undef, "Item has been returned"); - - $schema->storage->txn_rollback; }; diff --git a/t/db_dependent/Koha/Checkouts.t b/t/db_dependent/Koha/Checkouts.t index 312029037ac..deb166fdbad 100755 --- a/t/db_dependent/Koha/Checkouts.t +++ b/t/db_dependent/Koha/Checkouts.t @@ -165,6 +165,8 @@ subtest 'patron' => sub { } )->store; + t::lib::Mocks::mock_userenv( { branchcode => $library->{branchcode} } ); + my $p = $checkout->patron; is( ref($p), 'Koha::Patron', 'Koha::Checkout->patron should return a Koha::Patron' ); -- 2.39.3 (Apple Git-146)