Bugzilla – Attachment 182129 Details for
Bug 23010
If an item is checked out or in transit it should not be able to be marked withdrawn
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23010: Add tests for AutomaticItemModificationByAge
Bug-23010-Add-tests-for-AutomaticItemModificationB.patch (text/plain), 4.37 KB, created by
Lucas Gass (lukeg)
on 2025-05-08 22:25:57 UTC
(
hide
)
Description:
Bug 23010: Add tests for AutomaticItemModificationByAge
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-05-08 22:25:57 UTC
Size:
4.37 KB
patch
obsolete
>From 3dd8614748d022f16f8e8e4cdf51311065403ac0 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Thu, 8 May 2025 22:23:07 +0000 >Subject: [PATCH] Bug 23010: Add tests for AutomaticItemModificationByAge > >--- > .../Items/AutomaticItemModificationByAge.t | 106 +++++++++++++++++- > 1 file changed, 105 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Items/AutomaticItemModificationByAge.t b/t/db_dependent/Items/AutomaticItemModificationByAge.t >index 79dff9425b5..1978257599f 100755 >--- a/t/db_dependent/Items/AutomaticItemModificationByAge.t >+++ b/t/db_dependent/Items/AutomaticItemModificationByAge.t >@@ -2,7 +2,7 @@ > > use Modern::Perl; > use Test::NoWarnings; >-use Test::More tests => 21; >+use Test::More tests => 23; > use MARC::Record; > use MARC::Field; > use DateTime; >@@ -391,6 +391,110 @@ C4::Items::ToggleNewStatus( { rules => \@rules } ); > $modified_item = Koha::Items->find($itemnumber); > is( $modified_item->new_status, 'new_updated_value_biblio', q|ToggleNewStatus: conditions on biblio| ); > >+# Test for error handling in ToggleNewStatus with an on-loan item >+subtest "ToggleNewStatus onloan error handling" => sub { >+ plan tests => 3; >+ >+ # Create a new test item >+ my $test_item2 = $builder->build_object( { class => 'Koha::Items' } ); >+ my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ # Check out the item to create the condition for an error >+ $test_item2->checkout( $patron2->borrowernumber ); >+ ok( $test_item2->onloan, "Item is checked out" ); >+ >+ # Create rules to try to modify the withdrawn status >+ my @withdrawal_rules = ( >+ { >+ conditions => [ >+ { >+ field => "items.itemnumber", >+ value => $test_item2->itemnumber >+ } >+ ], >+ substitutions => [ >+ { >+ field => "items.withdrawn", >+ value => 1 >+ } >+ ] >+ } >+ ); >+ >+ # Run ToggleNewStatus with the rules and catch errors in the report >+ my $error_report = C4::Items::ToggleNewStatus( >+ { >+ rules => \@withdrawal_rules, >+ report_only => 0 >+ } >+ ); >+ >+ # Verify report structure >+ ok( exists $error_report->{ $test_item2->itemnumber }, "Error item appears in report" ); >+ >+ is( $test_item2->withdrawn, 0, 'Item should not be withdrawn' ); >+ >+}; >+ >+subtest "ToggleNewStatus in-transit error handling" => sub { >+ plan tests => 3; >+ >+ # Create a new test item >+ my $test_item3 = $builder->build_object( { class => 'Koha::Items' } ); >+ >+ # Create a transfer to put item in-transit >+ my $from_library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $to_library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ >+ my $transfer = Koha::Item::Transfer->new( >+ { >+ itemnumber => $test_item3->itemnumber, >+ frombranch => $from_library->branchcode, >+ tobranch => $to_library->branchcode, >+ datesent => dt_from_string(), >+ } >+ )->store; >+ >+ # Mark transfer as in transit >+ $transfer->datearrived(undef); >+ $transfer->store; >+ >+ # Verify item is in transit >+ my $item_transfer = $test_item3->get_transfer; >+ ok( $item_transfer && !$item_transfer->datearrived, "Item is in transit" ); >+ >+ # Create rules to try to modify the withdrawn status >+ my @withdrawal_rules = ( >+ { >+ conditions => [ >+ { >+ field => "items.itemnumber", >+ value => $test_item3->itemnumber >+ } >+ ], >+ substitutions => [ >+ { >+ field => "items.withdrawn", >+ value => 1 >+ } >+ ] >+ } >+ ); >+ >+ # Run ToggleNewStatus with the rules and catch errors in the report >+ my $error_report = C4::Items::ToggleNewStatus( >+ { >+ rules => \@withdrawal_rules, >+ report_only => 0 >+ } >+ ); >+ >+ # Verify report structure >+ ok( exists $error_report->{ $test_item3->itemnumber }, "Error item appears in report" ); >+ >+ is( $test_item3->withdrawn, 0, 'Item should not be withdrawn' ); >+}; >+ > # Run twice > t::lib::Mocks::mock_preference( 'CataloguingLog', 1 ); > my $actions_nb = $schema->resultset('ActionLog')->count(); >-- >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 23010
:
176241
|
177299
|
177402
|
177413
|
177434
|
177435
|
177436
|
177437
|
177451
|
177452
|
177453
|
177454
|
177911
|
177912
|
177913
|
177914
|
178808
|
181322
|
181323
|
181324
|
181325
|
181326
|
181327
|
181400
|
182124
| 182129 |
182130
|
182131