|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 6; |
20 |
use Test::More tests => 7; |
| 21 |
use Test::Mojo; |
21 |
use Test::Mojo; |
| 22 |
use Test::Warn; |
22 |
use Test::Warn; |
| 23 |
|
23 |
|
|
Lines 356-358
subtest 'list_desks() tests' => sub {
Link Here
|
| 356 |
|
356 |
|
| 357 |
$schema->storage->txn_rollback; |
357 |
$schema->storage->txn_rollback; |
| 358 |
}; |
358 |
}; |
| 359 |
- |
359 |
|
|
|
360 |
subtest 'list_cash_registers() tests' => sub { |
| 361 |
|
| 362 |
plan tests => 11; |
| 363 |
|
| 364 |
$schema->storage->txn_begin; |
| 365 |
|
| 366 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 367 |
my $patron = $builder->build_object( |
| 368 |
{ |
| 369 |
class => 'Koha::Patrons', |
| 370 |
value => { flags => 4 } |
| 371 |
} |
| 372 |
); |
| 373 |
my $password = 'thePassword123'; |
| 374 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
| 375 |
my $userid = $patron->userid; |
| 376 |
|
| 377 |
t::lib::Mocks::mock_preference( 'UseCashRegisters', 0 ); |
| 378 |
|
| 379 |
$t->get_ok( "//$userid:$password@/api/v1/libraries/" . $library->branchcode . "/cash_registers" )->status_is(404) |
| 380 |
->json_is( '/error' => q{Feature disabled} ); |
| 381 |
|
| 382 |
my $non_existent_code = $library->branchcode; |
| 383 |
$library->delete; |
| 384 |
|
| 385 |
t::lib::Mocks::mock_preference( 'UseCashRegisters', 1 ); |
| 386 |
|
| 387 |
$t->get_ok( "//$userid:$password@/api/v1/libraries/" . $non_existent_code . "/cash_registers" )->status_is(404) |
| 388 |
->json_is( '/error' => 'Library not found' ); |
| 389 |
|
| 390 |
my $cash_register_1 = |
| 391 |
$builder->build_object( { class => 'Koha::Cash::Registers', value => { branch => $library->id } } ); |
| 392 |
my $cash_register_2 = |
| 393 |
$builder->build_object( { class => 'Koha::Cash::Registers', value => { branch => $library->id } } ); |
| 394 |
|
| 395 |
my $res = |
| 396 |
$t->get_ok( "//$userid:$password@/api/v1/libraries/" . $library->branchcode . "/cash_registers" ) |
| 397 |
->status_is(200)->json_is( '/0/cash_register_id' => $cash_register_1->id ) |
| 398 |
->json_is( '/1/cash_register_id' => $cash_register_2->id )->tx->res->json; |
| 399 |
|
| 400 |
is( scalar @{$res}, 2 ); |
| 401 |
|
| 402 |
$schema->storage->txn_rollback; |
| 403 |
}; |