From 85255ef18f68e4c9899081777863b95db4a08fca Mon Sep 17 00:00:00 2001 From: Magnus Enger Date: Thu, 13 Nov 2014 18:43:29 +0000 Subject: [PATCH] Bug 11401: QA followup - Make the tests pass The configs in koha-conf.xml needed to be mocked. There was also a problem with how the NorwegianPatronDBEndpoint syspref was getting checked in the .pm. Signed-off-by: Tomas Cohen Arazi --- Koha/NorwegianPatronDB.pm | 7 +++---- t/NorwegianPatronDB.t | 10 +++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Koha/NorwegianPatronDB.pm b/Koha/NorwegianPatronDB.pm index c38d687cc2..03afc215d4 100644 --- a/Koha/NorwegianPatronDB.pm +++ b/Koha/NorwegianPatronDB.pm @@ -79,7 +79,6 @@ our %EXPORT_TAGS = ( all => [qw( Exporter::export_ok_tags('all'); my $nl_uri = 'http://lanekortet.no'; -my $nl_proxy = C4::Context->preference("NorwegianPatronDBEndpoint"); =head2 SOAP::Transport::HTTP::Client::get_basic_credentials @@ -156,7 +155,7 @@ sub NLSearch { my $client = SOAP::Lite ->on_action( sub { return '""';}) ->uri( $nl_uri ) - ->proxy( $nl_proxy ); + ->proxy( C4::Context->preference("NorwegianPatronDBEndpoint") ); my $id = SOAP::Data->type('string'); $id->name('identifikator'); @@ -236,7 +235,7 @@ sub NLSync { my $client = SOAP::Lite ->on_action( sub { return '""';}) ->uri( $nl_uri ) - ->proxy( $nl_proxy ); + ->proxy( C4::Context->preference("NorwegianPatronDBEndpoint") ); my $cardnumber = SOAP::Data->name( 'lnr' => $patron->cardnumber ); @@ -289,7 +288,7 @@ sub NLGetChanged { my $client = SOAP::Lite ->on_action( sub { return '""';}) ->uri( $nl_uri ) - ->proxy( $nl_proxy ); + ->proxy( C4::Context->preference("NorwegianPatronDBEndpoint") ); my $from_string; if ( $from_arg && $from_arg ne '' ) { diff --git a/t/NorwegianPatronDB.t b/t/NorwegianPatronDB.t index acbe04587f..4f05d916b3 100644 --- a/t/NorwegianPatronDB.t +++ b/t/NorwegianPatronDB.t @@ -16,7 +16,7 @@ # along with Koha; if not, see . use Modern::Perl; -use Test::More; +use Test::More tests => 73; use Test::MockModule; use t::lib::Mocks; use Data::Dumper; @@ -113,10 +113,16 @@ Relevant sysprefs: =cut +BEGIN { + t::lib::Mocks::mock_config('nlkey', 'key'); + t::lib::Mocks::mock_config('nlvendoruser', 'user'); + t::lib::Mocks::mock_config('nlvendorpass', 'pass'); +} t::lib::Mocks::mock_preference('NorwegianPatronDBEnable', 0); t::lib::Mocks::mock_preference('NorwegianPatronDBEndpoint', ''); t::lib::Mocks::mock_preference('NorwegianPatronDBUsername', ''); t::lib::Mocks::mock_preference('NorwegianPatronDBPassword', ''); + ok( my $result = NLCheckSysprefs(), 'call NLCheckSysprefs() ok' ); is( $result->{ 'error' }, 1, 'error detected' ); is( $result->{ 'nlenabled' }, 0, 'NL is not enabled' ); @@ -298,8 +304,6 @@ is( $res->{'melding'}, 'ingen treff', 'got "ingen treff"' ); is( $res->{'antall_poster_returnert'}, 0, 'got 0 records' ); is( $res->{'antall_treff'}, 0, 'got 0 records' ); -done_testing(); - =head1 SAMPLE SOAP XML RESPONSES These responses can be gathered by setting "outputxml()" to true on the SOAP -- 2.39.5