Lines 19-29
use Modern::Perl;
Link Here
|
19 |
|
19 |
|
20 |
use CGI qw ( -utf8 ); |
20 |
use CGI qw ( -utf8 ); |
21 |
|
21 |
|
22 |
use Test::More tests => 10; |
22 |
use Test::More tests => 11; |
23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
24 |
use t::lib::Mocks; |
24 |
use t::lib::Mocks; |
25 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
26 |
use t::lib::Dates; |
26 |
use t::lib::Dates; |
|
|
27 |
use XML::LibXML; |
27 |
|
28 |
|
28 |
use C4::Items qw( ModItemTransfer ); |
29 |
use C4::Items qw( ModItemTransfer ); |
29 |
use C4::Circulation qw( AddIssue ); |
30 |
use C4::Circulation qw( AddIssue ); |
Lines 32-38
use Koha::AuthUtils;
Link Here
|
32 |
use Koha::DateUtils qw( dt_from_string ); |
33 |
use Koha::DateUtils qw( dt_from_string ); |
33 |
|
34 |
|
34 |
BEGIN { |
35 |
BEGIN { |
35 |
use_ok('C4::ILSDI::Services', qw( AuthenticatePatron GetPatronInfo LookupPatron HoldTitle HoldItem GetRecords RenewLoan )); |
36 |
use_ok('C4::ILSDI::Services', qw( AuthenticatePatron GetPatronInfo LookupPatron HoldTitle HoldItem GetRecords RenewLoan GetAvailability )); |
36 |
} |
37 |
} |
37 |
|
38 |
|
38 |
my $schema = Koha::Database->schema; |
39 |
my $schema = Koha::Database->schema; |
Lines 788-790
subtest 'GetPatronInfo paginated loans' => sub {
Link Here
|
788 |
|
789 |
|
789 |
$schema->storage->txn_rollback; |
790 |
$schema->storage->txn_rollback; |
790 |
}; |
791 |
}; |
791 |
- |
792 |
|
|
|
793 |
subtest 'GetAvailability itemcallnumber' => sub { |
794 |
|
795 |
plan tests => 4; |
796 |
|
797 |
$schema->storage->txn_begin; |
798 |
|
799 |
t::lib::Mocks::mock_preference( 'ILS-DI', 1 ); |
800 |
|
801 |
my $item1 = $builder->build_sample_item( |
802 |
{ |
803 |
itemcallnumber => "callnumber", |
804 |
} |
805 |
); |
806 |
|
807 |
my $item2 = $builder->build_sample_item( {} ); |
808 |
|
809 |
# Build the query |
810 |
my $cgi = CGI->new; |
811 |
$cgi->param( service => 'GetAvailability' ); |
812 |
$cgi->param( id => $item1->itemnumber ); |
813 |
$cgi->param( id_type => 'item' ); |
814 |
|
815 |
# Output of GetAvailability is a string containing XML |
816 |
my $reply = C4::ILSDI::Services::GetAvailability($cgi); |
817 |
|
818 |
# Parse the output and get info |
819 |
my $result_XML = XML::LibXML->load_xml( string => $reply ); |
820 |
my $reply_callnumber = |
821 |
$result_XML->findnodes('//dlf:itemcallnumber')->to_literal(); |
822 |
|
823 |
# Test the output |
824 |
is( $reply_callnumber, $item1->itemcallnumber, |
825 |
"GetAvailability item has an itemcallnumber tag" ); |
826 |
|
827 |
$cgi = CGI->new; |
828 |
$cgi->param( service => 'GetAvailability' ); |
829 |
$cgi->param( id => $item2->itemnumber ); |
830 |
$cgi->param( id_type => 'item' ); |
831 |
$reply = C4::ILSDI::Services::GetAvailability($cgi); |
832 |
$result_XML = XML::LibXML->load_xml( string => $reply ); |
833 |
$reply_callnumber = |
834 |
$result_XML->findnodes('//dlf:itemcallnumber')->to_literal(); |
835 |
is( $reply_callnumber, '', |
836 |
"As expected, GetAvailability item has no itemcallnumber tag" ); |
837 |
|
838 |
$cgi = CGI->new; |
839 |
$cgi->param( service => 'GetAvailability' ); |
840 |
$cgi->param( id => $item1->biblionumber ); |
841 |
$cgi->param( id_type => 'biblio' ); |
842 |
$reply = C4::ILSDI::Services::GetAvailability($cgi); |
843 |
$result_XML = XML::LibXML->load_xml( string => $reply ); |
844 |
$reply_callnumber = |
845 |
$result_XML->findnodes('//dlf:itemcallnumber')->to_literal(); |
846 |
is( $reply_callnumber, $item1->itemcallnumber, |
847 |
"GetAvailability biblio has an itemcallnumber tag" ); |
848 |
|
849 |
$cgi = CGI->new; |
850 |
$cgi->param( service => 'GetAvailability' ); |
851 |
$cgi->param( id => $item2->biblionumber ); |
852 |
$cgi->param( id_type => 'biblio' ); |
853 |
$reply = C4::ILSDI::Services::GetAvailability($cgi); |
854 |
$result_XML = XML::LibXML->load_xml( string => $reply ); |
855 |
$reply_callnumber = |
856 |
$result_XML->findnodes('//dlf:itemcallnumber')->to_literal(); |
857 |
is( $reply_callnumber, '', |
858 |
"As expected, GetAvailability biblio has no itemcallnumber tag" ); |
859 |
|
860 |
$schema->storage->txn_rollback; |
861 |
}; |