Lines 20-26
use Modern::Perl;
Link Here
|
20 |
use utf8; |
20 |
use utf8; |
21 |
use Encode; |
21 |
use Encode; |
22 |
|
22 |
|
23 |
use Test::More tests => 5; |
23 |
use Test::More tests => 6; |
24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
25 |
use Test::Mojo; |
25 |
use Test::Mojo; |
26 |
use Test::Warn; |
26 |
use Test::Warn; |
Lines 29-36
use t::lib::Mocks;
Link Here
|
29 |
use t::lib::TestBuilder; |
29 |
use t::lib::TestBuilder; |
30 |
|
30 |
|
31 |
use C4::Auth; |
31 |
use C4::Auth; |
|
|
32 |
use C4::Circulation qw( AddIssue AddReturn ); |
33 |
|
32 |
use Koha::Biblios; |
34 |
use Koha::Biblios; |
33 |
use Koha::Database; |
35 |
use Koha::Database; |
|
|
36 |
use Koha::Checkouts; |
37 |
use Koha::Old::Checkouts; |
34 |
|
38 |
|
35 |
my $schema = Koha::Database->new->schema; |
39 |
my $schema = Koha::Database->new->schema; |
36 |
my $builder = t::lib::TestBuilder->new; |
40 |
my $builder = t::lib::TestBuilder->new; |
Lines 494-496
subtest 'pickup_locations() tests' => sub {
Link Here
|
494 |
|
498 |
|
495 |
$schema->storage->txn_rollback; |
499 |
$schema->storage->txn_rollback; |
496 |
}; |
500 |
}; |
497 |
- |
501 |
|
|
|
502 |
subtest 'get_checkouts() tests' => sub { |
503 |
|
504 |
plan tests => 14; |
505 |
|
506 |
$schema->storage->txn_begin; |
507 |
|
508 |
my $patron = $builder->build_object( |
509 |
{ |
510 |
class => 'Koha::Patrons', |
511 |
value => { flags => 0 } |
512 |
} |
513 |
); |
514 |
my $password = 'thePassword123'; |
515 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
516 |
$patron->discard_changes; |
517 |
my $userid = $patron->userid; |
518 |
|
519 |
my $biblio = $builder->build_sample_biblio(); |
520 |
$t->get_ok("//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber . "/checkouts") |
521 |
->status_is(403); |
522 |
|
523 |
$patron->flags(1)->store; # circulate permissions |
524 |
|
525 |
$t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber . "/checkouts") |
526 |
->status_is(200) |
527 |
->json_is( '' => [], 'No checkouts on the biblio' ); |
528 |
|
529 |
my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
530 |
my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
531 |
|
532 |
AddIssue( $patron->unblessed, $item_1->barcode ); |
533 |
AddIssue( $patron->unblessed, $item_2->barcode ); |
534 |
|
535 |
my $ret = $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber . "/checkouts") |
536 |
->status_is(200) |
537 |
->tx->res->json; |
538 |
|
539 |
my $checkout_1 = Koha::Checkouts->find({ itemnumber => $item_1->id }); |
540 |
my $checkout_2 = Koha::Checkouts->find({ itemnumber => $item_2->id }); |
541 |
|
542 |
is_deeply( $ret, [ $checkout_1->to_api, $checkout_2->to_api ] ); |
543 |
|
544 |
AddReturn( $item_1->barcode ); |
545 |
|
546 |
$ret = $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber . "/checkouts") |
547 |
->status_is(200) |
548 |
->tx->res->json; |
549 |
|
550 |
is_deeply( $ret, [ $checkout_2->to_api ] ); |
551 |
|
552 |
$ret = $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber . "/checkouts?checked_in=1") |
553 |
->status_is(200) |
554 |
->tx->res->json; |
555 |
|
556 |
my $old_checkout_1 = Koha::Old::Checkouts->find( $checkout_1->id ); |
557 |
|
558 |
is_deeply( $ret, [ $old_checkout_1->to_api ] ); |
559 |
|
560 |
$schema->storage->txn_rollback; |
561 |
}; |