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 |
plan tests => 4; |
795 |
$schema->storage->txn_begin; |
796 |
|
797 |
t::lib::Mocks::mock_preference( 'ILS-DI', 1 ); |
798 |
|
799 |
my $item1 = $builder->build_sample_item( |
800 |
{ |
801 |
itemcallnumber => "callnumber", |
802 |
} |
803 |
); |
804 |
|
805 |
my $item2 = $builder->build_sample_item( |
806 |
{ |
807 |
} |
808 |
); |
809 |
|
810 |
# Build the query |
811 |
my $cgi = CGI->new; |
812 |
$cgi->param(service => 'GetAvailability'); |
813 |
$cgi->param(id => $item1->itemnumber); |
814 |
$cgi->param(id_type => 'item'); |
815 |
|
816 |
# Output of GetAvailability is a string containing XML |
817 |
my $reply = C4::ILSDI::Services::GetAvailability($cgi); |
818 |
|
819 |
# Parse the output and get info |
820 |
my $result_XML = XML::LibXML->load_xml(string => $reply); |
821 |
my $reply_callnumber = $result_XML->findnodes('//dlf:itemcallnumber')->to_literal(); |
822 |
|
823 |
# Test the output |
824 |
is($reply_callnumber, $item1->itemcallnumber, "GetAvailability item has an itemcallnumber tag"); |
825 |
|
826 |
$cgi = CGI->new; |
827 |
$cgi->param(service => 'GetAvailability'); |
828 |
$cgi->param(id => $item2->itemnumber); |
829 |
$cgi->param(id_type => 'item'); |
830 |
$reply = C4::ILSDI::Services::GetAvailability($cgi); |
831 |
$result_XML = XML::LibXML->load_xml(string => $reply); |
832 |
$reply_callnumber = $result_XML->findnodes('//dlf:itemcallnumber')->to_literal(); |
833 |
is($reply_callnumber, '', "As expected, GetAvailability item has no itemcallnumber tag"); |
834 |
|
835 |
$cgi = CGI->new; |
836 |
$cgi->param(service => 'GetAvailability'); |
837 |
$cgi->param(id => $item1->biblionumber); |
838 |
$cgi->param(id_type => 'biblio'); |
839 |
$reply = C4::ILSDI::Services::GetAvailability($cgi); |
840 |
$result_XML = XML::LibXML->load_xml(string => $reply); |
841 |
$reply_callnumber = $result_XML->findnodes('//dlf:itemcallnumber')->to_literal(); |
842 |
is($reply_callnumber, $item1->itemcallnumber, "GetAvailability biblio has an itemcallnumber tag"); |
843 |
|
844 |
$cgi = CGI->new; |
845 |
$cgi->param(service => 'GetAvailability'); |
846 |
$cgi->param(id => $item2->biblionumber); |
847 |
$cgi->param(id_type => 'biblio'); |
848 |
$reply = C4::ILSDI::Services::GetAvailability($cgi); |
849 |
$result_XML = XML::LibXML->load_xml(string => $reply); |
850 |
$reply_callnumber = $result_XML->findnodes('//dlf:itemcallnumber')->to_literal(); |
851 |
is($reply_callnumber, '', "As expected, GetAvailability biblio has no itemcallnumber tag"); |
852 |
|
853 |
$schema->storage->txn_rollback; |
854 |
|
855 |
|
856 |
}; |