|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 2; |
20 |
use Test::More tests => 3; |
| 21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 22 |
use Test::Mojo; |
22 |
use Test::Mojo; |
| 23 |
|
23 |
|
|
Lines 70-75
subtest 'list() tests' => sub {
Link Here
|
| 70 |
$schema->storage->txn_rollback; |
70 |
$schema->storage->txn_rollback; |
| 71 |
}; |
71 |
}; |
| 72 |
|
72 |
|
|
|
73 |
subtest 'list_old() tests' => sub { |
| 74 |
|
| 75 |
plan tests => 9; |
| 76 |
|
| 77 |
$schema->storage->txn_begin; |
| 78 |
|
| 79 |
my $patron = $builder->build_object({ |
| 80 |
class => 'Koha::Patrons', |
| 81 |
value => { flags => 2 ** 4 } # 'borrowers' flag == 4 |
| 82 |
}); |
| 83 |
my $password = 'thePassword123'; |
| 84 |
$patron->set_password({ password => $password, skip_validation => 1 }); |
| 85 |
my $userid = $patron->userid; |
| 86 |
|
| 87 |
$t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->id . '/holds/previous') |
| 88 |
->status_is( 200, 'SWAGGER3.2.2' ) |
| 89 |
->json_is( [] ); |
| 90 |
|
| 91 |
my $hold_1 = $builder->build_object({ class => 'Koha::Holds', value => { borrowernumber => $patron->id } }); |
| 92 |
$hold_1->cancel(); |
| 93 |
my $cancellationdate = $hold_1->cancellationdate; |
| 94 |
$cancellationdate =~ s/ \d\d:\d\d:\d\d//; |
| 95 |
$hold_1->cancellationdate( $cancellationdate ); |
| 96 |
my $hold_2 = $builder->build_object({ class => 'Koha::Holds', value => { borrowernumber => $patron->id } }); |
| 97 |
$hold_2->cancel(); |
| 98 |
$cancellationdate = $hold_2->cancellationdate; |
| 99 |
$cancellationdate =~ s/ \d\d:\d\d:\d\d//; |
| 100 |
$hold_2->cancellationdate( $cancellationdate ); |
| 101 |
|
| 102 |
$t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->id . '/holds/previous?_order_by=+me.hold_id') |
| 103 |
->status_is( 200, 'SWAGGER3.2.2' ) |
| 104 |
->json_is( '' => [ $hold_1->to_api, $hold_2->to_api ], 'Holds retrieved' ); |
| 105 |
|
| 106 |
my $non_existent_patron = $builder->build_object({ class => 'Koha::Patrons' }); |
| 107 |
my $non_existent_patron_id = $non_existent_patron->id; |
| 108 |
# get rid of the patron |
| 109 |
$non_existent_patron->delete; |
| 110 |
|
| 111 |
$t->get_ok("//$userid:$password@/api/v1/patrons/" . $non_existent_patron_id . '/holds/previous') |
| 112 |
->status_is( 404 ) |
| 113 |
->json_is( '/error' => 'Patron not found' ); |
| 114 |
|
| 115 |
$schema->storage->txn_rollback; |
| 116 |
}; |
| 117 |
|
| 73 |
subtest 'delete_public() tests' => sub { |
118 |
subtest 'delete_public() tests' => sub { |
| 74 |
|
119 |
|
| 75 |
plan tests => 13; |
120 |
plan tests => 13; |
| 76 |
- |
|
|