|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 98; |
20 |
use Test::More tests => 101; |
| 21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 22 |
use Test::Mojo; |
22 |
use Test::Mojo; |
| 23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
|
Lines 228-238
$t->get_ok( "//$userid:$password@/api/v1/checkouts/" . $issue2->issue_id . "/all
Link Here
|
| 228 |
my $new_date_due = Koha::DateUtils::dt_from_string( $issue2->date_due ); |
228 |
my $new_date_due = Koha::DateUtils::dt_from_string( $issue2->date_due ); |
| 229 |
$new_date_due->add(days => 2); |
229 |
$new_date_due->add(days => 2); |
| 230 |
$new_date_due = output_pref({ dateformat => "rfc3339", dt => $new_date_due }); |
230 |
$new_date_due = output_pref({ dateformat => "rfc3339", dt => $new_date_due }); |
|
|
231 |
diag("The new date due should be: $new_date_due"); |
| 231 |
$t->put_ok( "//$userid:$password@/api/v1/checkouts/" . $issue2->issue_id => json => { due_date => $new_date_due }) |
232 |
$t->put_ok( "//$userid:$password@/api/v1/checkouts/" . $issue2->issue_id => json => { due_date => $new_date_due }) |
| 232 |
->status_is(200, 'Due date updated successfully') |
233 |
->status_is(200, 'Due date updated successfully') |
| 233 |
->json_is('/due_date' => $new_date_due); |
234 |
->json_is('/due_date' => $new_date_due); |
| 234 |
|
235 |
|
|
|
236 |
# Test for date handling for client differs from server locale |
| 237 |
$new_date_due = $date_due->clone->set_time_zone( 'Australia/Sydney' ); |
| 238 |
$new_date_due->add(days => 2); |
| 239 |
my $offset_rfc3339 = $new_date_due . get_offset_string($new_date_due->offset); |
| 240 |
my $offset_servertime = output_pref({ dateformat => "rfc3339", dt => $new_date_due }); |
| 241 |
$t->put_ok( "//$userid:$password@/api/v1/checkouts/" . $issue2->issue_id => json => { due_date => $offset_rfc3339}) |
| 242 |
->status_is(200, 'Due date updated successfully') |
| 243 |
->json_is('/due_date' => $offset_servertime); |
| 244 |
|
| 235 |
$t->put_ok( "//$userid:$password@/api/v1/checkouts/" . $issue2->issue_id => json => { item_id => 3 }) |
245 |
$t->put_ok( "//$userid:$password@/api/v1/checkouts/" . $issue2->issue_id => json => { item_id => 3 }) |
| 236 |
->status_is(400, 'readOnly properties not updateable'); |
246 |
->status_is(400, 'readOnly properties not updateable'); |
| 237 |
|
247 |
|
| 238 |
$schema->storage->txn_rollback; |
248 |
$schema->storage->txn_rollback; |
| 239 |
- |
249 |
|
|
|
250 |
# Borrowed from 2020 release of DateTime |
| 251 |
sub get_offset_string { |
| 252 |
my $offset = shift; |
| 253 |
my $sep = ':'; |
| 254 |
|
| 255 |
my $sign = $offset < 0 ? '-' : '+'; |
| 256 |
|
| 257 |
$offset = abs($offset); |
| 258 |
|
| 259 |
my $hours = int( $offset / 3600 ); |
| 260 |
$offset %= 3600; |
| 261 |
my $mins = int( $offset / 60 ); |
| 262 |
$offset %= 60; |
| 263 |
my $secs = int($offset); |
| 264 |
|
| 265 |
return ( |
| 266 |
$secs |
| 267 |
? sprintf( '%s%02d%s%02d%s%02d', |
| 268 |
$sign, $hours, $sep, $mins, $sep, $secs ) |
| 269 |
: sprintf( '%s%02d%s%02d', $sign, $hours, $sep, $mins ) |
| 270 |
); |
| 271 |
} |