Lines 332-338
is( $modified_item->new_status, 'agefield_new_value', q|ToggleNewStatus: Age = 2
Link Here
|
332 |
|
332 |
|
333 |
# Play with the unit field |
333 |
# Play with the unit field |
334 |
$dt_today = dt_from_string; |
334 |
$dt_today = dt_from_string; |
335 |
my $hours2ago = dt_from_string->subtract( hours => 2 ); |
335 |
my $hours2ago = dt_from_string->subtract( hours => 2 ); |
336 |
my $hours10ago = dt_from_string->subtract( hours => 10 ); |
336 |
my $hours10ago = dt_from_string->subtract( hours => 10 ); |
337 |
$modified_item->itemlost_on($hours2ago)->store; |
337 |
$modified_item->itemlost_on($hours2ago)->store; |
338 |
$modified_item->dateaccessioned($hours10ago)->store; |
338 |
$modified_item->dateaccessioned($hours10ago)->store; |
Lines 350-359
$modified_item->dateaccessioned($hours10ago)->store;
Link Here
|
350 |
{ |
350 |
{ |
351 |
field => 'items.new_status', |
351 |
field => 'items.new_status', |
352 |
value => 'ageunit_new_value', |
352 |
value => 'ageunit_new_value', |
353 |
}, |
353 |
}, |
354 |
], |
354 |
], |
355 |
age => '5', |
355 |
age => '5', |
356 |
ageunit => 'Hours', |
356 |
ageunit => 'Hours', |
357 |
agefield => 'items.dateaccessioned' |
357 |
agefield => 'items.dateaccessioned' |
358 |
}, |
358 |
}, |
359 |
); |
359 |
); |
Lines 361-381
$modified_item->dateaccessioned($hours10ago)->store;
Link Here
|
361 |
# Confirm a rule with unit = 'Hours' does not work with fields other than items.damaged_on, |
361 |
# Confirm a rule with unit = 'Hours' does not work with fields other than items.damaged_on, |
362 |
# items.itemlost_on, or items.withdrawn_on |
362 |
# items.itemlost_on, or items.withdrawn_on |
363 |
C4::Items::ToggleNewStatus( { rules => \@rules } ); |
363 |
C4::Items::ToggleNewStatus( { rules => \@rules } ); |
364 |
$modified_item = Koha::Items->find( $itemnumber ); |
364 |
$modified_item = Koha::Items->find($itemnumber); |
365 |
is( $modified_item->new_status, 'agefield_new_value', q|ToggleNewStatus: Age = 5, ageunit = 'Hours', agefield = 'items.dateaccessioned' : The new_status value is not updated|); |
365 |
is( |
|
|
366 |
$modified_item->new_status, 'agefield_new_value', |
367 |
q|ToggleNewStatus: Age = 5, ageunit = 'Hours', agefield = 'items.dateaccessioned' : The new_status value is not updated| |
368 |
); |
366 |
|
369 |
|
367 |
# Confirm a rule on a datetime field (items.itemlost_on) with unit = 'Hours' does |
370 |
# Confirm a rule on a datetime field (items.itemlost_on) with unit = 'Hours' does |
368 |
# change an item correctly based on the age in hours |
371 |
# change an item correctly based on the age in hours |
369 |
$rules[0]->{agefield} = 'items.itemlost_on'; |
372 |
$rules[0]->{agefield} = 'items.itemlost_on'; |
370 |
C4::Items::ToggleNewStatus( { rules => \@rules } ); |
373 |
C4::Items::ToggleNewStatus( { rules => \@rules } ); |
371 |
$modified_item = Koha::Items->find( $itemnumber ); |
374 |
$modified_item = Koha::Items->find($itemnumber); |
372 |
$modified_item->itemlost_on; |
375 |
$modified_item->itemlost_on; |
373 |
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|); |
376 |
is( |
|
|
377 |
$modified_item->new_status, 'agefield_new_value', |
378 |
q|ToggleNewStatus: Age = 5, ageunit = 'Hours', agefield = 'items.itemlost_on' : The new_status value is not updated| |
379 |
); |
374 |
|
380 |
|
375 |
$rules[0]->{age} = 1; |
381 |
$rules[0]->{age} = 1; |
376 |
C4::Items::ToggleNewStatus( { rules => \@rules } ); |
382 |
C4::Items::ToggleNewStatus( { rules => \@rules } ); |
377 |
$modified_item = Koha::Items->find( $itemnumber ); |
383 |
$modified_item = Koha::Items->find($itemnumber); |
378 |
is( $modified_item->new_status, 'ageunit_new_value', q|ToggleNewStatus: Age = 1, ageunit = 'Hours', agefield = 'items.itemlost_on' : The new_status value is updated|); |
384 |
is( |
|
|
385 |
$modified_item->new_status, 'ageunit_new_value', |
386 |
q|ToggleNewStatus: Age = 1, ageunit = 'Hours', agefield = 'items.itemlost_on' : The new_status value is updated| |
387 |
); |
379 |
|
388 |
|
380 |
# Run twice |
389 |
# Run twice |
381 |
t::lib::Mocks::mock_preference('CataloguingLog', 1); |
390 |
t::lib::Mocks::mock_preference('CataloguingLog', 1); |