From ce0b3deb929d4a9377b87af1f2883c822261101d Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Mon, 27 Jan 2020 03:43:51 +0100 Subject: [PATCH] Bug 12469: Added Unit tests for GetAvailability --- t/db_dependent/ILSDI_Services.t | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t index 430d900c77..9d6ea6bb06 100644 --- a/t/db_dependent/ILSDI_Services.t +++ b/t/db_dependent/ILSDI_Services.t @@ -18,8 +18,9 @@ use Modern::Perl; use CGI qw ( -utf8 ); +use XML::LibXML; -use Test::More tests => 9; +use Test::More tests => 10; use Test::MockModule; use t::lib::Mocks; use t::lib::TestBuilder; @@ -684,3 +685,32 @@ subtest 'GetPatronInfo paginated loans' => sub { $schema->storage->txn_rollback; }; + +subtest 'GetAvailability tests' => sub { + plan tests => 5; + + $schema->storage->txn_begin; + + my $library = $builder->build_object({ + class => 'Koha::Libraries', + }); + + my $item1 = $builder->build_sample_item({ library => $library->branchcode, + itemcallnumber => "CAL.123", + }); + + my $cgi = new CGI; + + $cgi->param( 'service', 'GetAvailability' ); + $cgi->param( 'id', $item1->itemnumber ); + $cgi->param( 'id_type', 'item' ); + my $reply = XML::LibXML->load_xml( string => C4::ILSDI::Services::GetAvailability($cgi) ); + + is($reply->findnodes('//dlf:identifier'), $item1->itemnumber, 'itemnumber valid'); + is($reply->findnodes('//dlf:availabilitystatus'), 'available', 'item1 is available'); + is($reply->findnodes('//dlf:location'), $library->branchname, 'item1 location (branchname) is fine'); + is($reply->findnodes('//dlf:callnumber'), $item1->itemcallnumber, 'item1 callnumber is returned too'); + is($reply->findnodes('//dlf:dateavailable'), DateTime->now , 'item1 available as of now'); + + $schema->storage->txn_rollback; +}; -- 2.20.1