|
Lines 40-46
my $t = Test::Mojo->new('Koha::REST::V1');
Link Here
|
| 40 |
|
40 |
|
| 41 |
subtest 'list() tests' => sub { |
41 |
subtest 'list() tests' => sub { |
| 42 |
|
42 |
|
| 43 |
plan tests => 21; |
43 |
plan tests => 24; |
| 44 |
|
44 |
|
| 45 |
# Mock ILLBackend (as object) |
45 |
# Mock ILLBackend (as object) |
| 46 |
my $backend = Test::MockObject->new; |
46 |
my $backend = Test::MockObject->new; |
|
Lines 81-87
subtest 'list() tests' => sub {
Link Here
|
| 81 |
$t->request_ok($tx)->status_is(200)->json_is( [] ); |
81 |
$t->request_ok($tx)->status_is(200)->json_is( [] ); |
| 82 |
|
82 |
|
| 83 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
83 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 84 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
84 |
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); |
|
|
85 |
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 85 |
|
86 |
|
| 86 |
# Create an ILL request |
87 |
# Create an ILL request |
| 87 |
my $illrequest = $builder->build_object( |
88 |
my $illrequest = $builder->build_object( |
|
Lines 90-96
subtest 'list() tests' => sub {
Link Here
|
| 90 |
value => { |
91 |
value => { |
| 91 |
backend => 'Mock', |
92 |
backend => 'Mock', |
| 92 |
branchcode => $library->branchcode, |
93 |
branchcode => $library->branchcode, |
| 93 |
borrowernumber => $patron->borrowernumber |
94 |
borrowernumber => $patron_1->borrowernumber |
| 94 |
} |
95 |
} |
| 95 |
} |
96 |
} |
| 96 |
); |
97 |
); |
|
Lines 114-120
subtest 'list() tests' => sub {
Link Here
|
| 114 |
$tx->req->env( { REMOTE_ADDR => $remote_address } ); |
115 |
$tx->req->env( { REMOTE_ADDR => $remote_address } ); |
| 115 |
$t->request_ok($tx)->status_is(200) |
116 |
$t->request_ok($tx)->status_is(200) |
| 116 |
->json_has( '/0/patron', 'patron embedded' ) |
117 |
->json_has( '/0/patron', 'patron embedded' ) |
| 117 |
->json_is( '/0/patron/patron_id', $patron->borrowernumber, 'The right patron is embeded') |
118 |
->json_is( '/0/patron/patron_id', $patron_1->borrowernumber, 'The right patron is embeded') |
| 118 |
->json_has( '/0/requested_partners', 'requested_partners embedded' ) |
119 |
->json_has( '/0/requested_partners', 'requested_partners embedded' ) |
| 119 |
->json_has( '/0/capabilities', 'capabilities embedded' ) |
120 |
->json_has( '/0/capabilities', 'capabilities embedded' ) |
| 120 |
->json_has( '/0/library', 'library embedded' ) |
121 |
->json_has( '/0/library', 'library embedded' ) |
|
Lines 128-134
subtest 'list() tests' => sub {
Link Here
|
| 128 |
value => { |
129 |
value => { |
| 129 |
backend => 'Mock', |
130 |
backend => 'Mock', |
| 130 |
branchcode => $library->branchcode, |
131 |
branchcode => $library->branchcode, |
| 131 |
borrowernumber => $patron->borrowernumber |
132 |
borrowernumber => $patron_2->borrowernumber |
| 132 |
} |
133 |
} |
| 133 |
} |
134 |
} |
| 134 |
); |
135 |
); |
|
Lines 154-159
subtest 'list() tests' => sub {
Link Here
|
| 154 |
[{ path => '/query/request_blah', message => 'Malformed query string'}] |
155 |
[{ path => '/query/request_blah', message => 'Malformed query string'}] |
| 155 |
); |
156 |
); |
| 156 |
|
157 |
|
|
|
158 |
# Test the borrowernumber parameter |
| 159 |
$tx = $t->ua->build_tx( GET => '/api/v1/illrequests?borrowernumber=' . |
| 160 |
$patron_2->borrowernumber ); |
| 161 |
$tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); |
| 162 |
$tx->req->env( { REMOTE_ADDR => $remote_address } ); |
| 163 |
$t->request_ok($tx)->status_is(200)->json_is( [ $response2 ] ); |
| 164 |
|
| 157 |
$schema->storage->txn_rollback; |
165 |
$schema->storage->txn_rollback; |
| 158 |
}; |
166 |
}; |
| 159 |
|
167 |
|
| 160 |
- |
|
|