Bug 32019: Unit tests
authorNick Clemens <nick@bywatersolutions.com>
Thu, 27 Oct 2022 16:13:05 +0000 (16:13 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 20 Feb 2023 12:54:19 +0000 (09:54 -0300)
Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
t/db_dependent/Koha/Items/BatchUpdate.t

index 2a3811e..af6e5b6 100755 (executable)
@@ -16,7 +16,8 @@
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 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;