Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 5; |
20 |
use Test::More tests => 6; |
21 |
use Test::Mojo; |
21 |
use Test::Mojo; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
|
23 |
|
Lines 315-317
subtest 'delete() tests' => sub {
Link Here
|
315 |
|
315 |
|
316 |
$schema->storage->txn_rollback; |
316 |
$schema->storage->txn_rollback; |
317 |
}; |
317 |
}; |
318 |
- |
318 |
|
|
|
319 |
subtest 'list_desks() tests' => sub { |
320 |
|
321 |
plan tests => 11; |
322 |
|
323 |
$schema->storage->txn_begin; |
324 |
|
325 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
326 |
my $patron = $builder->build_object( |
327 |
{ |
328 |
class => 'Koha::Patrons', |
329 |
value => { flags => 4 } |
330 |
} |
331 |
); |
332 |
my $password = 'thePassword123'; |
333 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
334 |
my $userid = $patron->userid; |
335 |
|
336 |
t::lib::Mocks::mock_preference( 'UseCirculationDesks', 0 ); |
337 |
|
338 |
$t->get_ok( "//$userid:$password@/api/v1/libraries/" . $library->branchcode . "/desks" )->status_is(404) |
339 |
->json_is( '/error' => q{Feature disabled} ); |
340 |
|
341 |
my $non_existent_code = $library->branchcode; |
342 |
$library->delete; |
343 |
|
344 |
t::lib::Mocks::mock_preference( 'UseCirculationDesks', 1 ); |
345 |
|
346 |
$t->get_ok( "//$userid:$password@/api/v1/libraries/" . $non_existent_code . "/desks" )->status_is(404) |
347 |
->json_is( '/error' => 'Library not found' ); |
348 |
|
349 |
my $desk_1 = $builder->build_object( { class => 'Koha::Desks', value => { branchcode => $library->id } } ); |
350 |
my $desk_2 = $builder->build_object( { class => 'Koha::Desks', value => { branchcode => $library->id } } ); |
351 |
|
352 |
my $res = $t->get_ok( "//$userid:$password@/api/v1/libraries/" . $library->branchcode . "/desks" )->status_is(200) |
353 |
->json_is( '/0/desk_id' => $desk_1->id )->json_is( '/1/desk_id' => $desk_2->id )->tx->res->json; |
354 |
|
355 |
is( scalar @{$res}, 2 ); |
356 |
|
357 |
$schema->storage->txn_rollback; |
358 |
}; |