Bugzilla – Attachment 176006 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 _status tests
Bug-37334-Add-status-tests.patch (text/plain), 5.77 KB, created by
Lucas Gass (lukeg)
on 2024-12-30 15:31:58 UTC
(
hide
)
Description:
Bug 37334: Add _status tests
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2024-12-30 15:31:58 UTC
Size:
5.77 KB
patch
obsolete
>From ccf23ebd364e2336a3fff7537d22e1e164d5912b Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Tue, 19 Nov 2024 22:25:57 +0000 >Subject: [PATCH] Bug 37334: Add _status tests > >--- > t/db_dependent/Koha/Item.t | 140 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 139 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 7d115cdb3a..e100bb7242 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -20,7 +20,7 @@ > use Modern::Perl; > use utf8; > >-use Test::More tests => 38; >+use Test::More tests => 39; > use Test::Exception; > use Test::MockModule; > use Test::Warn; >@@ -45,6 +45,144 @@ use t::lib::Dates; > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > >+subtest '_status' => sub { >+ plan tests => 12; >+ >+ $schema->storage->txn_begin; >+ >+ my $item = $builder->build_sample_item(); >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ t::lib::Mocks::mock_userenv({ >+ branchcode => $library->branchcode >+ }); >+ >+ t::lib::Mocks::mock_preference('UseRecalls', 1); >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ my @test_cases = ( >+ { >+ setup => sub { >+ my $onloan_item = $builder->build_sample_item(); >+ AddIssue( $patron, $onloan_item->barcode, dt_from_string ); >+ return $onloan_item; >+ }, >+ expected_status => 'checked_out', >+ description => 'Checked out status correctly returned', >+ }, >+ { >+ setup => sub { >+ my $onsite_item = $builder->build_sample_item(); >+ AddIssue( $patron, $onsite_item->barcode, dt_from_string, undef, undef, undef, { onsite_checkout => 1 } ); >+ return $onsite_item; >+ }, >+ expected_status => 'local_use', >+ description => 'Local use status correctly returned', >+ }, >+ { >+ setup => sub { >+ return $item; >+ }, >+ expected_status => 'available', >+ description => 'Available status correctly returned', >+ }, >+ { >+ setup => sub { >+ $item->itemlost(1)->store(); >+ return $item; >+ }, >+ expected_status => 'lost', >+ description => 'Lost status correctly returned', >+ }, >+ { >+ setup => sub { >+ $item->withdrawn(1)->store(); >+ return $item; >+ }, >+ expected_status => qr/lost,withdrawn/, >+ description => 'Lost and withdrawn status correctly returned', >+ }, >+ { >+ setup => sub { >+ $item->damaged(1)->store(); >+ return $item; >+ }, >+ expected_status => qr/lost,withdrawn,damaged/, >+ description => 'Lost, withdrawn, and damaged status correctly returned', >+ }, >+ { >+ setup => sub { >+ $item->notforloan(1)->store(); >+ return $item; >+ }, >+ expected_status => 'not_for_loan', >+ description => 'Positive not_for_loan status correctly returned', >+ }, >+ { >+ setup => sub { >+ $item->notforloan(-1)->store(); >+ return $item; >+ }, >+ expected_status => 'not_for_loan', >+ description => 'Negative not_for_loan status correctly returned', >+ }, >+ { >+ setup => sub { >+ my $itemtype = $builder->build_object( { class => "Koha::ItemTypes", value => { notforloan => 1 } } ); >+ my $notforloan_item = $builder->build_sample_item( { itype => $itemtype->itemtype, } ); >+ return $notforloan_item; >+ }, >+ expected_status => 'not_for_loan', >+ description => 'Item type not_for_loan status correctly returned', >+ }, >+ { >+ setup => sub { >+ my $onhold_item = $builder->build_sample_item(); >+ C4::Reserves::AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $onhold_item->biblionumber, >+ itemnumber => $onhold_item->itemnumber, >+ } >+ ); >+ return $onhold_item; >+ }, >+ expected_status => 'on_hold', >+ description => 'On hold status correctly returned', >+ }, >+ { >+ setup => sub { >+ my $recalled_item = $builder->build_sample_item(); >+ AddIssue( $patron, $recalled_item->barcode, dt_from_string ); >+ Koha::Recalls->add_recall( >+ { biblio => $recalled_item->biblio, item => $recalled_item, patron => $patron } ); >+ return $recalled_item; >+ }, >+ expected_status => 'recalled', >+ description => 'Recalled status correctly returned', >+ }, >+ { >+ setup => sub { >+ $item->restricted(1)->store(); >+ return $item; >+ }, >+ expected_status => 'restricted', >+ description => 'Restricted status correctly returned', >+ }, >+ ); >+ >+ >+ foreach my $test_case (@test_cases) { >+ my $item = $test_case->{setup}->(); >+ ok( $item->_status() =~ /$test_case->{expected_status}/, $test_case->{description} ); >+ } >+ >+ t::lib::Mocks::mock_preference('UseRecalls', 0); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'z3950_status' => sub { > plan tests => 9; > >-- >2.39.2
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