From d550bcd90994f0cf77169d1370d721eb20ff291a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 22 Sep 2023 16:55:59 +0200 Subject: [PATCH] Bug 32496: Fix tests Signed-off-by: Tomas Cohen Arazi --- C4/SIP/ILS/Transaction/Renew.pm | 2 +- t/db_dependent/Items.t | 4 ++-- t/db_dependent/Koha/Acquisition/Order.t | 4 ++-- t/db_dependent/Koha/Holds.t | 2 +- t/db_dependent/Koha/Item.t | 14 +++++++------- t/db_dependent/Koha/Patron.t | 4 ++-- t/db_dependent/SIP/ILS.t | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/C4/SIP/ILS/Transaction/Renew.pm b/C4/SIP/ILS/Transaction/Renew.pm index 0d66326543..75ce5b569a 100644 --- a/C4/SIP/ILS/Transaction/Renew.pm +++ b/C4/SIP/ILS/Transaction/Renew.pm @@ -47,7 +47,7 @@ sub do_renew_for { } if ($renewokay){ - my $issue = AddIssue( $patron->unblessed, $self->{item}->id, undef, 0 ); + my $issue = AddIssue( $patron, $self->{item}->id, undef, 0 ); $self->{due} = $self->duedatefromissue($issue, $self->{item}->{itemnumber}); $self->renewal_ok(1); } else { diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index 3112745551..84932499af 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -455,8 +455,8 @@ subtest 'SearchItems test' => sub { is($total_results, 1, 'found all items of library1 with new_status=0 with ifnull = 0'); t::lib::Mocks::mock_userenv({ branchcode => $item1->homebranch }); - my $patron_borrower = $builder->build_object({ class => 'Koha::Patrons' })->unblessed; - AddIssue( $patron_borrower, $item1->barcode ); + my $patron = $builder->build_object({ class => 'Koha::Patrons' }); + AddIssue( $patron, $item1->barcode ); # Search item where item is checked out $filter = { conjunction => 'AND', diff --git a/t/db_dependent/Koha/Acquisition/Order.t b/t/db_dependent/Koha/Acquisition/Order.t index 8a47a5cfce..10fdfa4685 100755 --- a/t/db_dependent/Koha/Acquisition/Order.t +++ b/t/db_dependent/Koha/Acquisition/Order.t @@ -698,7 +698,7 @@ subtest 'cancel() tests' => sub { t::lib::Mocks::mock_userenv({ patron => $patron }); # Add a checkout so deleting the item fails because od 'book_on_loan' - C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); + C4::Circulation::AddIssue( $patron, $item->barcode ); my $result = $order->cancel({ reason => $reason }); # refresh the order object @@ -966,7 +966,7 @@ subtest 'cancel() tests' => sub { $order->add_item( $item_3->id ); # Add a checkout so deleting the item fails because od 'book_on_loan' - C4::Circulation::AddIssue( $patron->unblessed, $item_2->barcode ); + C4::Circulation::AddIssue( $patron, $item_2->barcode ); C4::Reserves::AddReserve( { branchcode => $item_3->holdingbranch, diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t index 4b859cfa3d..762bd889c6 100755 --- a/t/db_dependent/Koha/Holds.t +++ b/t/db_dependent/Koha/Holds.t @@ -483,7 +483,7 @@ subtest 'get_items_that_can_fill' => sub { ); # item 3 is on loan - AddIssue( $patron_3->unblessed, $item_3->barcode ); + AddIssue( $patron_3, $item_3->barcode ); # item 4 is in transfer my $from = $builder->build_object( { class => 'Koha::Libraries' } ); diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index 176e8feed1..9552eb8adf 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -263,14 +263,14 @@ subtest 'add_to_bundle tests' => sub { 'Koha::Exceptions::Item::Bundle::IsBundle', 'Exception thrown if you try to add a bundle host to a bundle item'; - C4::Circulation::AddIssue( $patron->unblessed, $host_item->barcode ); + C4::Circulation::AddIssue( $patron, $host_item->barcode ); throws_ok { $host_item->add_to_bundle($bundle_item2) } 'Koha::Exceptions::Item::Bundle::BundleIsCheckedOut', 'Exception thrown if you try to add an item to a checked out bundle'; C4::Circulation::AddReturn( $host_item->barcode, $host_item->homebranch ); $host_item->discard_changes; - C4::Circulation::AddIssue( $patron->unblessed, $bundle_item2->barcode ); + C4::Circulation::AddIssue( $patron, $bundle_item2->barcode ); throws_ok { $host_item->add_to_bundle($bundle_item2) } 'Koha::Exceptions::Item::Bundle::ItemIsCheckedOut', 'Exception thrown if you try to add a checked out item'; @@ -304,7 +304,7 @@ subtest 'remove_from_bundle tests' => sub { my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); t::lib::Mocks::mock_userenv( { branchcode => $patron->branchcode } ); - C4::Circulation::AddIssue( $patron->unblessed, $host_item->barcode ); + C4::Circulation::AddIssue( $patron, $host_item->barcode ); throws_ok { $bundle_item1->remove_from_bundle } 'Koha::Exceptions::Item::Bundle::BundleIsCheckedOut', 'Exception thrown if you try to add an item to a checked out bundle'; @@ -871,7 +871,7 @@ subtest 'deletion' => sub { $item = $builder->build_sample_item({ library => $library->branchcode }); # book_on_loan - C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); + C4::Circulation::AddIssue( $patron, $item->barcode ); is( @{$item->safe_to_delete->messages}[0]->message, @@ -1973,7 +1973,7 @@ subtest 'Recalls tests' => sub { is( $item1->can_be_recalled({ patron => $patron1 }), 0, "Can't recall item if not checked out" ); $item1->update({ withdrawn => 0 }); - C4::Circulation::AddIssue( $patron2->unblessed, $item1->barcode ); + C4::Circulation::AddIssue( $patron2, $item1->barcode ); Koha::CirculationRules->set_rules({ branchcode => $branchcode, @@ -2023,7 +2023,7 @@ subtest 'Recalls tests' => sub { C4::Circulation::AddReturn( $item1->barcode, $branchcode ); is( $item1->can_be_recalled({ patron => $patron1 }), 0, "Can't recall if no items are checked out" ); - C4::Circulation::AddIssue( $patron2->unblessed, $item1->barcode ); + C4::Circulation::AddIssue( $patron2, $item1->barcode ); is( $item1->can_be_recalled({ patron => $patron1 }), 1, "Can recall item" ); $recall1 = Koha::Recall->new( @@ -2168,7 +2168,7 @@ subtest 'has_pending_recall() tests' => sub { t::lib::Mocks::mock_userenv({ branchcode => $library->branchcode }); t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); - C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); + C4::Circulation::AddIssue( $patron, $item->barcode ); my ($recall) = Koha::Recalls->add_recall({ biblio => $item->biblio, item => $item, patron => $patron }); diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t index b2c82dfb9c..85a6ae6198 100755 --- a/t/db_dependent/Koha/Patron.t +++ b/t/db_dependent/Koha/Patron.t @@ -1504,8 +1504,8 @@ subtest 'get_savings tests' => sub { is( $patron->get_savings, 0, 'No checkouts with itemnumber, no savings' ); - AddIssue( $patron->unblessed, $item1->barcode ); - AddIssue( $patron->unblessed, $item2->barcode ); + AddIssue( $patron, $item1->barcode ); + AddIssue( $patron, $item2->barcode ); my $savings = $patron->get_savings; is( $savings + 0, $item1->replacementprice + $item2->replacementprice, "Savings correctly calculated from current issues" ); diff --git a/t/db_dependent/SIP/ILS.t b/t/db_dependent/SIP/ILS.t index 5943e4036e..b0bcdbfd8d 100755 --- a/t/db_dependent/SIP/ILS.t +++ b/t/db_dependent/SIP/ILS.t @@ -345,7 +345,7 @@ subtest renew => sub { } ); - AddIssue( $patron->unblessed, $item->barcode, undef, 0 ); + AddIssue( $patron, $item->barcode, undef, 0 ); my $checkout = $item->checkout; ok( defined($checkout), "Successfully checked out an item prior to renewal" ); -- 2.39.5