Lines 35-41
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
Link Here
|
35 |
|
35 |
|
36 |
subtest 'list() tests' => sub { |
36 |
subtest 'list() tests' => sub { |
37 |
|
37 |
|
38 |
plan tests => 9; |
38 |
plan tests => 18; |
39 |
|
39 |
|
40 |
$schema->storage->txn_begin; |
40 |
$schema->storage->txn_begin; |
41 |
|
41 |
|
Lines 51-62
subtest 'list() tests' => sub {
Link Here
|
51 |
->status_is( 200, 'SWAGGER3.2.2' ) |
51 |
->status_is( 200, 'SWAGGER3.2.2' ) |
52 |
->json_is( [] ); |
52 |
->json_is( [] ); |
53 |
|
53 |
|
54 |
my $hold_1 = $builder->build_object({ class => 'Koha::Holds', value => { borrowernumber => $patron->id } }); |
54 |
my $hold_1 = $builder->build_object( { class => 'Koha::Holds', value => { borrowernumber => $patron->id } } ); |
55 |
my $hold_2 = $builder->build_object({ class => 'Koha::Holds', value => { borrowernumber => $patron->id } }); |
55 |
my $hold_2 = $builder->build_object( { class => 'Koha::Holds', value => { borrowernumber => $patron->id } } ); |
|
|
56 |
my $hold_3 = $builder->build_object( { class => 'Koha::Holds', value => { borrowernumber => $patron->id } } ); |
56 |
|
57 |
|
57 |
$t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->id . '/holds?_order_by=+me.hold_id') |
58 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron->id . '/holds?_order_by=+me.hold_id' ) |
58 |
->status_is( 200, 'SWAGGER3.2.2' ) |
59 |
->status_is( 200, 'SWAGGER3.2.2' ) |
59 |
->json_is( '' => [ $hold_1->to_api, $hold_2->to_api ], 'Holds retrieved' ); |
60 |
->json_is( '' => [ $hold_1->to_api, $hold_2->to_api, $hold_3->to_api ], 'Holds retrieved' ); |
|
|
61 |
|
62 |
$hold_1->fill; |
63 |
$hold_3->fill; |
64 |
|
65 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron->id . '/holds?_order_by=+me.hold_id' ) |
66 |
->status_is( 200, 'SWAGGER3.2.2' )->json_is( '' => [ $hold_2->to_api ], 'Only current holds retrieved' ); |
67 |
|
68 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron->id . '/holds?old=1&_order_by=+me.hold_id' ) |
69 |
->status_is( 200, 'SWAGGER3.2.2' ) |
70 |
->json_is( '' => [ $hold_1->to_api, $hold_3->to_api ], 'Only old holds retrieved' ); |
71 |
|
72 |
my $old_hold_1 = Koha::Old::Holds->find( $hold_1->id ); |
73 |
$old_hold_1->item->delete; |
74 |
$old_hold_1->pickup_library->delete; |
75 |
|
76 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron->id . '/holds?old=1&_order_by=+me.hold_id' ) |
77 |
->status_is( 200, 'SWAGGER3.2.2' )->json_is( |
78 |
'' => [ $old_hold_1->get_from_storage->to_api, $hold_3->to_api ], |
79 |
'Old holds even after item and library removed' |
80 |
); |
60 |
|
81 |
|
61 |
my $non_existent_patron = $builder->build_object({ class => 'Koha::Patrons' }); |
82 |
my $non_existent_patron = $builder->build_object({ class => 'Koha::Patrons' }); |
62 |
my $non_existent_patron_id = $non_existent_patron->id; |
83 |
my $non_existent_patron_id = $non_existent_patron->id; |
63 |
- |
|
|