Bugzilla – Attachment 138872 Details for
Bug 21173
Add hours as age unit to auto item modifications by age for damaged_on, itemlost_on and withdrawn_on fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21173: Unit tests
Bug-21173-Unit-tests.patch (text/plain), 3.27 KB, created by
Alex Buckley
on 2022-08-09 04:50:00 UTC
(
hide
)
Description:
Bug 21173: Unit tests
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2022-08-09 04:50:00 UTC
Size:
3.27 KB
patch
obsolete
>From f32dcebf8de236ba91552b5cc3ac591d38038643 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Tue, 9 Aug 2022 16:03:03 +1200 >Subject: [PATCH] Bug 21173: Unit tests > >Test plan: >1. sudo koha-shell kohadev >2. prove t/db_dependent/Items/AutomaticItemModificationByAge.t > >Sponsored-by: Toi Ohomai Institute of Technology, New Zealand >--- > .../Items/AutomaticItemModificationByAge.t | 49 ++++++++++++++++++- > 1 file changed, 48 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Items/AutomaticItemModificationByAge.t b/t/db_dependent/Items/AutomaticItemModificationByAge.t >index 61e6100362e..089b975d394 100755 >--- a/t/db_dependent/Items/AutomaticItemModificationByAge.t >+++ b/t/db_dependent/Items/AutomaticItemModificationByAge.t >@@ -1,7 +1,7 @@ > #!/usr/bin/perl > > use Modern::Perl; >-use Test::More tests => 19; >+use Test::More tests => 22; > use MARC::Record; > use MARC::Field; > use DateTime; >@@ -331,6 +331,53 @@ C4::Items::ToggleNewStatus( { rules => \@rules } ); > $modified_item = Koha::Items->find( $itemnumber ); > is( $modified_item->new_status, 'agefield_new_value', q|ToggleNewStatus: Age = 2, agefield = 'items.datelastseen' : The new_status value is updated|); > >+# Play with the unit field >+$dt_today = dt_from_string; >+my $hours2ago = dt_from_string->subtract( hours => 2 ); >+my $hours10ago = dt_from_string->subtract( hours => 10 ); >+$modified_item->itemlost_on($hours2ago)->store; >+$modified_item->dateaccessioned($hours10ago)->store; >+ >+# When agefield='items.dateaccessioned' and unit='Hours' >+@rules = ( >+ { >+ conditions => [ >+ { >+ field => 'biblioitems.itemtype', >+ value => 'ITEMTYPE_T', >+ }, >+ ], >+ substitutions => [ >+ { >+ field => 'items.new_status', >+ value => 'ageunit_new_value', >+ }, >+ ], >+ age => '5', >+ ageunit => 'Hours', >+ agefield => 'items.dateaccessioned' >+ }, >+); >+ >+# Confirm a rule with unit = 'Hours' does not work with fields other than items.damaged_on, >+# items.itemlost_on, or items.withdrawn_on >+C4::Items::ToggleNewStatus( { rules => \@rules } ); >+$modified_item = Koha::Items->find( $itemnumber ); >+is( $modified_item->new_status, 'agefield_new_value', q|ToggleNewStatus: Age = 5, ageunit = 'Hours', agefield = 'items.dateaccessioned' : The new_status value is not updated|); >+ >+# Confirm a rule on a datetime field (items.itemlost_on) with unit = 'Hours' does >+# change an item correctly based on the age in hours >+$rules[0]->{agefield} = 'items.itemlost_on'; >+C4::Items::ToggleNewStatus( { rules => \@rules } ); >+$modified_item = Koha::Items->find( $itemnumber ); >+$modified_item->itemlost_on; >+is( $modified_item->new_status, 'agefield_new_value', q|ToggleNewStatus: Age = 5, ageunit = 'Hours', agefield = 'items.itemlost_on' : The new_status value is not updated|); >+ >+$rules[0]->{age} = 1; >+C4::Items::ToggleNewStatus( { rules => \@rules } ); >+$modified_item = Koha::Items->find( $itemnumber ); >+is( $modified_item->new_status, 'ageunit_new_value', q|ToggleNewStatus: Age = 1, ageunit = 'Hours', agefield = 'items.itemlost_on' : The new_status value is updated|); >+ > # Run twice > t::lib::Mocks::mock_preference('CataloguingLog', 1); > my $actions_nb = $schema->resultset('ActionLog')->count(); >-- >2.20.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 21173
:
77547
|
77548
|
77604
|
77605
|
78917
|
79914
|
138870
|
138871
|
138872
|
138894
|
138895
|
138896
|
156137
|
156138
|
156139
|
158574
|
158575
|
160715
|
160716