Lines 231-236
subtest 'update() tests' => sub {
Link Here
|
231 |
my $patron_1 = Koha::Patrons->find($borrowernumber); |
231 |
my $patron_1 = Koha::Patrons->find($borrowernumber); |
232 |
my $patron_2 = Koha::Patrons->find($borrowernumber2); |
232 |
my $patron_2 = Koha::Patrons->find($borrowernumber2); |
233 |
my $newpatron = $patron_2->TO_JSON; |
233 |
my $newpatron = $patron_2->TO_JSON; |
|
|
234 |
# borrowernumber should not be passed in the request body for PUT |
235 |
delete $newpatron->{borrowernumber}; |
234 |
|
236 |
|
235 |
my $tx = $t->ua->build_tx(PUT => "/api/v1/patrons/-1" => json => $newpatron ); |
237 |
my $tx = $t->ua->build_tx(PUT => "/api/v1/patrons/-1" => json => $newpatron ); |
236 |
$tx->req->cookies({name => 'CGISESSID', value => $sessionid}); |
238 |
$tx->req->cookies({name => 'CGISESSID', value => $sessionid}); |
Lines 282-294
subtest 'update() tests' => sub {
Link Here
|
282 |
$newpatron->{ userid } = "user".$borrowernumber.$borrowernumber2; |
284 |
$newpatron->{ userid } = "user".$borrowernumber.$borrowernumber2; |
283 |
$newpatron->{ surname } = "user".$borrowernumber.$borrowernumber2; |
285 |
$newpatron->{ surname } = "user".$borrowernumber.$borrowernumber2; |
284 |
|
286 |
|
285 |
$tx = $t->ua->build_tx(PUT => "/api/v1/patrons/" . |
287 |
$tx = $t->ua->build_tx(PUT => "/api/v1/patrons/" . $patron_2->id => json => $newpatron); |
286 |
$newpatron->{borrowernumber} => json => $newpatron); |
|
|
287 |
$tx->req->cookies({name => 'CGISESSID', value => $sessionid}); |
288 |
$tx->req->cookies({name => 'CGISESSID', value => $sessionid}); |
288 |
$t->request_ok($tx) |
289 |
$t->request_ok($tx) |
289 |
->status_is(200, 'Patron updated successfully') |
290 |
->status_is(200, 'Patron updated successfully') |
290 |
->json_has($newpatron); |
291 |
->json_has($newpatron); |
291 |
is(Koha::Patrons->find($newpatron->{borrowernumber})->cardnumber, |
292 |
is(Koha::Patrons->find( $patron_2->id )->cardnumber, |
292 |
$newpatron->{ cardnumber }, 'Patron is really updated!'); |
293 |
$newpatron->{ cardnumber }, 'Patron is really updated!'); |
293 |
}; |
294 |
}; |
294 |
|
295 |
|
295 |
- |
|
|