From 39fb3c71a634f2ad66efe446d96857a8e3ec0e28 Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Sat, 4 Jan 2020 21:17:15 +0100 Subject: [PATCH] Bug 23015: Adding tests for GetPickupLocation method --- t/db_dependent/ILSDI_Services.t | 61 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t index b1288ec469..d42289abbb 100644 --- a/t/db_dependent/ILSDI_Services.t +++ b/t/db_dependent/ILSDI_Services.t @@ -19,7 +19,7 @@ use Modern::Perl; use CGI qw ( -utf8 ); -use Test::More tests => 9; +use Test::More tests => 10; use Test::MockModule; use t::lib::Mocks; use t::lib::TestBuilder; @@ -544,6 +544,65 @@ subtest 'Holds test for branch transfer limits' => sub { $schema->storage->txn_rollback; }; +subtest 'GetPickupLocation test' => sub { + + plan tests => 5; + + $schema->storage->txn_begin; + + my $pickup_branch = $builder->build( + { + source => 'Branch', + value => { + pickup_location => 1, + } + } + ); + + my $biblio = $builder->build({ + source => 'Biblio', + }); + my $biblioitem = $builder->build({ + source => 'Biblioitem', + value => { + biblionumber => $biblio->{biblionumber}, + } + }); + my $item = $builder->build({ + source => 'Item', + value => { + homebranch => $pickup_branch->{branchcode}, + holdingbranch => $pickup_branch->{branchcode}, + biblionumber => $biblio->{biblionumber}, + } + }); + + my $patron = $builder->build({ + source => 'Borrower', + }); + + my $query = new CGI; + + my $reply = C4::ILSDI::Services::GetPickupLocation( $query ); + is( $reply->{error}, 'PatronNotFound', "Patron not found" ); + + $query->param( 'patron_id', $patron->{borrowernumber}); + $reply = C4::ILSDI::Services::GetPickupLocation( $query ); + is( $reply->{error}, 'MissingParameter', 'Id type undefined' ); + + $query->param( 'id_type', 'bib'); + $query->param( 'id', '105799999' ); + $reply = C4::ILSDI::Services::GetPickupLocation( $query ); + is( $reply->{error}, 'RecordNotFound', 'Record not found' ); + + $query->param( 'id', $biblio->{biblionumber}); + $reply = C4::ILSDI::Services::GetPickupLocation( $query ); + is( $reply->{error}, undef, 'no error' ); + is( defined $reply->{library}, 1, 'got branchcode' ); + + $schema->storage->txn_rollback; +}; + subtest 'GetRecords' => sub { plan tests => 1; -- 2.11.0