Bugzilla – Attachment 177432 Details for
Bug 37334
Cannot filter holdings table by status
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37334: Add search tests
Bug-37334-Add-search-tests.patch (text/plain), 4.88 KB, created by
Lucas Gass (lukeg)
on 2025-01-31 21:52:23 UTC
(
hide
)
Description:
Bug 37334: Add search tests
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-01-31 21:52:23 UTC
Size:
4.88 KB
patch
obsolete
>From 176833935ab818a7fddad835b7295168d4ffa1f6 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Wed, 29 Jan 2025 21:33:20 +0000 >Subject: [PATCH] Bug 37334: Add search tests > >--- > t/db_dependent/Koha/Items.t | 131 +++++++++++++++++++++++++++++++++++- > 1 file changed, 130 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index 716396fe8c0..0a293dea673 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 26; >+use Test::More tests => 27; > > use Test::MockModule; > use Test::Exception; >@@ -69,6 +69,135 @@ is( Koha::Items->search->count, $nb_of_items + 2, 'The 2 items should have been > my $retrieved_item_1 = Koha::Items->find( $new_item_1->itemnumber ); > is( $retrieved_item_1->barcode, $new_item_1->barcode, 'Find a item by id should return the correct item' ); > >+subtest 'search' => sub { >+ >+ plan tests => 9; >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $patron_2 = $builder->build_object( { class => 'Koha::Patrons' } ); >+ t::lib::Mocks::mock_userenv( { branchcode => $patron->branchcode } ); >+ >+ my $library_1 = $builder->build( { source => 'Branch' } ); >+ my $library_2 = $builder->build( { source => 'Branch' } ); >+ >+ my $biblio = $builder->build_sample_biblio(); >+ >+ my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, }); >+ my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, }); >+ >+ my $available_items = Koha::Items->search({ >+ _status => 'available', >+ biblionumber => $biblio->biblionumber, >+ }); >+ >+ ok($available_items->count == 2, "Filtered to 2 available items"); >+ >+ my $item_3 = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ itemlost => 1, >+ }); >+ >+ my $item_4 = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ damaged => 1, >+ }); >+ >+ my $item_5 = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ withdrawn => 1, >+ }); >+ >+ my $item_6 = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ notforloan => 1, >+ }); >+ >+ my $lost_items = Koha::Items->search({ >+ _status => 'lost', >+ biblionumber => $biblio->biblionumber, >+ }); >+ >+ my $damaged_items = Koha::Items->search({ >+ _status => 'damaged', >+ biblionumber => $biblio->biblionumber, >+ }); >+ >+ my $withdrawn_items = Koha::Items->search({ >+ _status => 'withdrawn', >+ biblionumber => $biblio->biblionumber, >+ }); >+ >+ my $notforloan_items = Koha::Items->search({ >+ _status => 'not_for_loan', >+ biblionumber => $biblio->biblionumber, >+ }); >+ >+ ok($lost_items->count == 1, "Filtered to 1 lost item"); >+ ok($damaged_items->count == 1, "Filtered to 1 damaged item"); >+ ok($withdrawn_items->count == 1, "Filtered to 1 withdrawn item"); >+ ok($notforloan_items->count == 1, "Filtered to 1 notforloan item"); >+ >+ C4::Circulation::AddIssue( $patron, $item_1->barcode ); >+ >+ my $checked_out_items = Koha::Items->search({ >+ _status => 'checked_out', >+ biblionumber => $biblio->biblionumber, >+ }); >+ >+ ok($checked_out_items->count == 1, "Filtered to 1 checked out item"); >+ >+ my $transfer_1 = $builder->build_object( >+ { >+ class => 'Koha::Item::Transfers', >+ value => { >+ itemnumber => $item_2->itemnumber, >+ frombranch => $library_1->{branchcode}, >+ tobranch => $library_2->{branchcode}, >+ } >+ } >+ ); >+ >+ my $in_transit_items = Koha::Items->search({ >+ _status => 'in_transit', >+ biblionumber => $biblio->biblionumber, >+ }); >+ >+ ok($in_transit_items->count == 1, "Filtered to 1 in transit item"); >+ >+ my $item_7 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, }); >+ >+ my $hold_1 = $builder->build( >+ { >+ source => 'Reserve', >+ value => { >+ itemnumber => $item_7->itemnumber, reservedate => dt_from_string, >+ } >+ } >+ ); >+ >+ my $on_hold_items = Koha::Items->search({ >+ _status => 'on_hold', >+ biblionumber => $biblio->biblionumber, >+ }); >+ >+ ok($on_hold_items->count == 1, "Filtered to 1 on hold item"); >+ >+ my $item_8 = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ restricted => 1, >+ }); >+ >+ my $restricted_items = Koha::Items->search({ >+ _status => 'restricted', >+ biblionumber => $biblio->biblionumber, >+ }); >+ >+ ok($restricted_items->count == 1, "Filtered to 1 restricted item"); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'store' => sub { > plan tests => 8; > >-- >2.39.5
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 37334
:
172300
|
172301
|
172302
|
173499
|
173500
|
173501
|
173949
|
173950
|
173951
|
173982
|
174310
|
174798
|
174799
|
174800
|
174801
|
174802
|
174803
|
174804
|
174813
|
174814
|
174901
|
174902
|
174903
|
174955
|
175859
|
175860
|
175861
|
175862
|
175863
|
175864
|
175865
|
175866
|
175867
|
175868
|
175869
|
175870
|
175871
|
175999
|
176000
|
176001
|
176002
|
176003
|
176004
|
176005
|
176006
|
176007
|
176008
|
176009
|
176010
|
176011
|
176023
|
176024
|
176025
|
176026
|
176027
|
176028
|
176029
|
176030
|
176031
|
176032
|
176033
|
176034
|
176035
|
176475
|
176477
|
176480
|
176481
|
177321
|
177415
|
177416
|
177417
|
177418
|
177419
|
177420
|
177421
|
177422
|
177423
|
177424
|
177425
|
177426
|
177427
|
177428
|
177429
|
177430
|
177431
| 177432