|
Lines 189-195
subtest 'add() tests' => sub {
Link Here
|
| 189 |
$schema->storage->txn_rollback; |
189 |
$schema->storage->txn_rollback; |
| 190 |
|
190 |
|
| 191 |
subtest 'librarian access tests' => sub { |
191 |
subtest 'librarian access tests' => sub { |
| 192 |
plan tests => 22; |
192 |
plan tests => 24; |
| 193 |
|
193 |
|
| 194 |
$schema->storage->txn_begin; |
194 |
$schema->storage->txn_begin; |
| 195 |
|
195 |
|
|
Lines 284-289
subtest 'add() tests' => sub {
Link Here
|
| 284 |
delete $newpatron->{anonymized}; |
284 |
delete $newpatron->{anonymized}; |
| 285 |
$patron_to_delete->delete; |
285 |
$patron_to_delete->delete; |
| 286 |
|
286 |
|
|
|
287 |
# Set a date field |
| 288 |
$newpatron->{date_of_birth} = '1980-06-18'; |
| 289 |
# Set a date-time field |
| 290 |
$newpatron->{last_seen} = output_pref({ dt => dt_from_string->add( days => -1 ), dateformat => 'rfc3339' }); |
| 291 |
|
| 287 |
$t->post_ok("//$userid:$password@/api/v1/patrons" => json => $newpatron) |
292 |
$t->post_ok("//$userid:$password@/api/v1/patrons" => json => $newpatron) |
| 288 |
->status_is(201, 'Patron created successfully') |
293 |
->status_is(201, 'Patron created successfully') |
| 289 |
->header_like( |
294 |
->header_like( |
|
Lines 291-299
subtest 'add() tests' => sub {
Link Here
|
| 291 |
'SWAGGER3.4.1' |
296 |
'SWAGGER3.4.1' |
| 292 |
) |
297 |
) |
| 293 |
->json_has('/patron_id', 'got a patron_id') |
298 |
->json_has('/patron_id', 'got a patron_id') |
| 294 |
->json_is( '/cardnumber' => $newpatron->{ cardnumber }) |
299 |
->json_is( '/cardnumber' => $newpatron->{ cardnumber }) |
| 295 |
->json_is( '/surname' => $newpatron->{ surname }) |
300 |
->json_is( '/surname' => $newpatron->{ surname }) |
| 296 |
->json_is( '/firstname' => $newpatron->{ firstname }); |
301 |
->json_is( '/firstname' => $newpatron->{ firstname }) |
|
|
302 |
->json_is( '/date_of_birth' => $newpatron->{ date_of_birth }, 'Date field set (Bug 28585)' ) |
| 303 |
->json_is( '/last_seen' => $newpatron->{ last_seen }, 'Date-time field set (Bug 28585)' ); |
| 297 |
|
304 |
|
| 298 |
warning_like { |
305 |
warning_like { |
| 299 |
$t->post_ok("//$userid:$password@/api/v1/patrons" => json => $newpatron) |
306 |
$t->post_ok("//$userid:$password@/api/v1/patrons" => json => $newpatron) |
|
Lines 432-438
subtest 'update() tests' => sub {
Link Here
|
| 432 |
$schema->storage->txn_rollback; |
439 |
$schema->storage->txn_rollback; |
| 433 |
|
440 |
|
| 434 |
subtest 'librarian access tests' => sub { |
441 |
subtest 'librarian access tests' => sub { |
| 435 |
plan tests => 42; |
442 |
plan tests => 44; |
| 436 |
|
443 |
|
| 437 |
$schema->storage->txn_begin; |
444 |
$schema->storage->txn_begin; |
| 438 |
|
445 |
|
|
Lines 548-554
subtest 'update() tests' => sub {
Link Here
|
| 548 |
is_deeply($got, $newpatron, 'Returned patron from update matches expected'); |
555 |
is_deeply($got, $newpatron, 'Returned patron from update matches expected'); |
| 549 |
t::lib::Dates::compare( $updated_on_got, $updated_on_expected, 'updated_on values matched' ); |
556 |
t::lib::Dates::compare( $updated_on_got, $updated_on_expected, 'updated_on values matched' ); |
| 550 |
|
557 |
|
| 551 |
|
|
|
| 552 |
is(Koha::Patrons->find( $patron_2->id )->cardnumber, |
558 |
is(Koha::Patrons->find( $patron_2->id )->cardnumber, |
| 553 |
$newpatron->{ cardnumber }, 'Patron is really updated!'); |
559 |
$newpatron->{ cardnumber }, 'Patron is really updated!'); |
| 554 |
|
560 |
|
|
Lines 611-619
subtest 'update() tests' => sub {
Link Here
|
| 611 |
delete $newpatron->{email}; |
617 |
delete $newpatron->{email}; |
| 612 |
delete $newpatron->{secondary_email}; |
618 |
delete $newpatron->{secondary_email}; |
| 613 |
delete $newpatron->{altaddress_email}; |
619 |
delete $newpatron->{altaddress_email}; |
|
|
620 |
|
| 621 |
# Set a date field |
| 622 |
$newpatron->{date_of_birth} = '1980-06-18'; |
| 623 |
# Set a date-time field |
| 624 |
$newpatron->{last_seen} = output_pref({ dt => dt_from_string->add( days => -1 ), dateformat => 'rfc3339' }); |
| 625 |
|
| 614 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" . $superlibrarian->borrowernumber => json => $newpatron ) |
626 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" . $superlibrarian->borrowernumber => json => $newpatron ) |
| 615 |
->status_is(200, "Non-superlibrarian user can edit superlibrarian successfully if not changing email"); |
627 |
->status_is(200, "Non-superlibrarian user can edit superlibrarian successfully if not changing email") |
| 616 |
# ->json_is( { error => "Not enough privileges to change a superlibrarian's email" } ); |
628 |
->json_is( '/date_of_birth' => $newpatron->{ date_of_birth }, 'Date field set (Bug 28585)' ) |
|
|
629 |
->json_is( '/last_seen' => $newpatron->{ last_seen }, 'Date-time field set (Bug 28585)' ); |
| 617 |
|
630 |
|
| 618 |
$schema->storage->txn_rollback; |
631 |
$schema->storage->txn_rollback; |
| 619 |
}; |
632 |
}; |
| 620 |
- |
|
|