From 0b6947c983804c61cab74041862277d886ac3acc Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 27 Oct 2022 16:13:05 +0000 Subject: [PATCH] Bug 32019: Unit tests Signed-off-by: Andrew Fuerste-Henry --- t/db_dependent/Koha/Items/BatchUpdate.t | 29 ++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Items/BatchUpdate.t b/t/db_dependent/Koha/Items/BatchUpdate.t index 2a3811e141..af6e5b6c43 100755 --- a/t/db_dependent/Koha/Items/BatchUpdate.t +++ b/t/db_dependent/Koha/Items/BatchUpdate.t @@ -16,7 +16,8 @@ # along with Koha; if not, see . use Modern::Perl; -use Test::More tests=> 7; +use Test::More tests=> 8; +use Test::Warn; use utf8; use Koha::Database; @@ -27,6 +28,7 @@ use Koha::Item::Attributes; use Koha::MarcSubfieldStructures; use t::lib::TestBuilder; +use t::lib::Mocks; my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; @@ -252,6 +254,31 @@ subtest 'encoding' => sub { is( $item->as_marc_field->subfield('é'), 'new note é', ); }; +subtest 'mark_items_returned' => sub { + plan tests => 2; + + my $circ = Test::MockModule->new( 'C4::Circulation' ); + $circ->mock( 'MarkIssueReturned', sub { + warn "MarkIssueReturned"; + }); + + my $issue = $builder->build_object({class => 'Koha::Checkouts'}); + my $items = Koha::Items->search({ itemnumber => $issue->itemnumber }); + + warning_is + { $items->batch_update({new_values => {},mark_items_returned => 1}) } + qq{MarkIssueReturned}, + "MarkIssueReturned called for item"; + + $items->reset; + + warning_is + { $items->batch_update({new_values => {},mark_items_returned => 0}) } + qq{}, + "MarkIssueReturned not called for item"; + +}; + subtest 'report' => sub { plan tests => 5; -- 2.30.2