Bug 33641: (follow-up) Fix unit tests

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Matt Blenkinsop 2024-11-15 11:19:12 +00:00 committed by Katrin Fischer
parent 26e5852890
commit 16d04b16b7
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
4 changed files with 10 additions and 4 deletions

View File

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

View File

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

View File

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

View File

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