Bugzilla – Attachment 177779 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 filter_by_available tests
Bug-37334-Add-filterbyavailable-tests.patch (text/plain), 4.33 KB, created by
Lucas Gass (lukeg)
on 2025-02-11 20:46:14 UTC
(
hide
)
Description:
Bug 37334: Add filter_by_available tests
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-02-11 20:46:14 UTC
Size:
4.33 KB
patch
obsolete
>From 864ce399552e2a44c22daed5d375670d596e1437 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Mon, 13 Jan 2025 23:25:49 +0000 >Subject: [PATCH] Bug 37334: Add filter_by_available tests > >Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >--- > t/db_dependent/Koha/Items.t | 127 +++++++++++++++++++++++++++++++++++- > 1 file changed, 126 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index af5500811cb..264988d2aa3 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 => 25; >+use Test::More tests => 26; > > use Test::MockModule; > use Test::Exception; >@@ -2608,3 +2608,128 @@ subtest 'filter_by_has_recalls' => sub { > $schema->storage->txn_rollback; > > }; >+ >+subtest 'filter_by_available' => sub { >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $biblio = $builder->build_sample_biblio(); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ t::lib::Mocks::mock_userenv( { branchcode => $patron->branchcode } ); >+ >+ my $item_1 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library->branchcode, >+ itemlost => 0, >+ withdrawn => 0, >+ damaged => 0, >+ notforloan => 0, >+ onloan => undef, >+ } >+ ); >+ >+ my $item_2 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library->branchcode, >+ itemlost => 0, >+ withdrawn => 0, >+ damaged => 0, >+ notforloan => 0, >+ onloan => undef, >+ } >+ ); >+ >+ my $item_3 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library->branchcode, >+ itemlost => 0, >+ withdrawn => 0, >+ damaged => 0, >+ notforloan => 0, >+ onloan => undef, >+ } >+ ); >+ >+ my $item_4 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library->branchcode, >+ itemlost => 0, >+ withdrawn => 0, >+ damaged => 0, >+ notforloan => 0, >+ onloan => undef, >+ } >+ ); >+ >+ my $item_5 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library->branchcode, >+ itemlost => 0, >+ withdrawn => 0, >+ damaged => 0, >+ notforloan => 0, >+ onloan => undef, >+ } >+ ); >+ >+ # Create items with varying states >+ # Test: Initial available items >+ is( >+ $biblio->items->filter_by_available->count, >+ 5, >+ "Filtered to 4 available items" >+ ); >+ >+ # Mark item_1 as lost >+ $item_1->itemlost(3)->store; >+ C4::Circulation::LostItem( $item_1->itemnumber, 1 ); >+ >+ is( >+ $biblio->items->filter_by_available->count, >+ 4, >+ "Filtered to 4 available items, 1 is lost" >+ ); >+ >+ #Mark item_2 as damaged >+ $item_2->damaged(1)->store; >+ >+ is( >+ $biblio->items->filter_by_available->count, >+ 3, >+ "Filtered to 3 available items, 1 is lost, 1 is damaged" >+ ); >+ >+ #Mark item_3 as withdrawn >+ $item_3->withdrawn(1)->store; >+ >+ is( >+ $biblio->items->filter_by_available->count, >+ 2, >+ "Filtered to 2 available items, 1 is lost, 1 is damaged, 1 is withdrawn" >+ ); >+ >+ #Checkout item_4 >+ C4::Circulation::AddIssue( $patron, $item_4->barcode ); >+ is( >+ $biblio->items->filter_by_available->count, >+ 1, >+ "Filtered to 1 available items, 1 is lost, 1 is damaged, 1 is withdrawn, 1 is checked out" >+ ); >+ >+ #Mark item_5 as notforloan >+ $item_5->notforloan(1)->store; >+ is( >+ $biblio->items->filter_by_available->count, >+ 0, >+ "Filtered to 0 available items, 1 is lost, 1 is damaged, 1 is withdrawn, 1 is checked out, 1 is notforloan" >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >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
|
177466
|
177516
|
177520
|
177524
|
177525
|
177526
|
177527
|
177528
|
177529
|
177530
|
177531
|
177764
|
177765
|
177766
|
177767
|
177768
|
177769
|
177770
|
177771
|
177772
|
177773
|
177774
|
177775
|
177776
|
177777
|
177778
|
177779
|
177780
|
177781
|
177782
|
177783
|
178620
|
178621
|
178622
|
178623
|
178624
|
178625
|
178626
|
178627
|
178628
|
178629
|
178630
|
178631
|
178632
|
178633
|
178634
|
178635
|
178636
|
178637
|
180064
|
180157
|
180158
|
180159
|
180160
|
180161
|
180162
|
180163
|
180164
|
180165
|
180166
|
180167
|
180168
|
180169
|
180170
|
180171
|
180172
|
180173
|
180174
|
180175
|
180196
|
181161
|
181162
|
181163
|
181164
|
181165
|
181166
|
181167
|
181169
|
181170
|
181171
|
181172
|
181173
|
181174
|
181175
|
181176
|
181177
|
181178
|
181179
|
181180
|
181181
|
181632
|
182359
|
182360
|
182361
|
182362
|
182363
|
182364
|
182365
|
182366
|
182367
|
182368
|
182369
|
182370
|
182371
|
182372
|
182373
|
182374
|
182375
|
182376
|
182552
|
182665
|
182733