Bugzilla – Attachment 175396 Details for
Bug 38686
Add Koha::Items->filter_by_checked_out
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38686: Unit tests
Bug-38686-Unit-tests.patch (text/plain), 2.21 KB, created by
Tomás Cohen Arazi (tcohen)
on 2024-12-12 13:22:12 UTC
(
hide
)
Description:
Bug 38686: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2024-12-12 13:22:12 UTC
Size:
2.21 KB
patch
obsolete
>From bb75a84829e1fc60517bb46687d49de7fcdd22ce Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 12 Dec 2024 10:18:22 -0300 >Subject: [PATCH] Bug 38686: Unit tests > >--- > t/db_dependent/Koha/Items.t | 39 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 38 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index 03b26550eb4..64ae1a071e2 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -19,12 +19,14 @@ > > use Modern::Perl; > >-use Test::More tests => 20; >+use Test::More tests => 21; > > use Test::MockModule; > use Test::Exception; > use Time::Fake; > >+use List::MoreUtils qw(none); >+ > use C4::Circulation qw( AddIssue LostItem AddReturn ); > use C4::Context; > use C4::Serials qw( NewIssue AddItem2Serial ); >@@ -2222,3 +2224,38 @@ subtest 'filter_by_bookable' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'filter_by_checked_out() tests' => sub { >+ >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ >+ my $item_1 = $builder->build_sample_item(); >+ my $item_2 = $builder->build_sample_item(); >+ my $item_3 = $builder->build_sample_item(); >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ t::lib::Mocks::mock_userenv( { patron => $patron, branchcode => $patron->branchcode } ); >+ >+ my $items = Koha::Items->search( { 'me.itemnumber' => [ $item_1->id, $item_2->id, $item_3->id ] } ); >+ >+ is( $items->count, 3, '3 items in the resultset' ); >+ >+ my $filtered_rs = $items->filter_by_checked_out(); >+ is( $filtered_rs->count, 0, 'No checked out items in the resultset' ); >+ >+ AddIssue( $patron, $item_3->barcode ); >+ $filtered_rs = $items->filter_by_checked_out(); >+ >+ is( $filtered_rs->count, 1, '1 item in the resultset' ); >+ is( $filtered_rs->next->id, $item_3->id, 'The checked out item remains in the resultset' ); >+ >+ AddIssue( $patron, $item_1->barcode ); >+ $filtered_rs = $items->filter_by_checked_out(); >+ >+ is( $filtered_rs->count, 2, '2 item in the resultset' ); >+ ok( ( none { $_->id == $item_2->id } $filtered_rs->as_list ), 'The item not checked out is not in the resultset' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.47.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38686
:
175396
|
175398
|
175763
|
175764