@@ -, +, @@ subroutine Fix QA script warnings --- C4/Serials.pm | 1 + Koha/SharedContent.pm | 19 +++++++++++++------ t/db_dependent/Koha/SharedContent.t | 7 +++++-- t/db_dependent/Koha/Subscription.t | 6 ++---- 4 files changed, 21 insertions(+), 12 deletions(-) --- a/C4/Serials.pm +++ a/C4/Serials.pm @@ -35,6 +35,7 @@ use Koha::DateUtils; use Koha::Serial; use Koha::Subscriptions; use Koha::Subscription::Histories; +use Koha::SharedContent; use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); --- a/Koha/SharedContent.pm +++ a/Koha/SharedContent.pm @@ -26,8 +26,6 @@ use Koha::Serials; use Koha::Reports; use C4::Context; -our $MANA_IP = C4::Context->config('mana_config'); - =head1 DESCRIPTION Package for accessing shared content via Mana @@ -151,13 +149,14 @@ sub manaGetRequest { sub buildRequest { my $type = shift; my $resource = shift; + my $mana_url = manaUrl(); if ( $type eq 'get' ) { my $params = shift; $params = join '&', map { defined $params->{$_} ? $_ . "=" . $params->{$_} : () } keys %$params; - my $url = "$MANA_IP/$resource.json?$params"; + my $url = "$mana_url/$resource.json?$params"; return HTTP::Request->new( GET => $url ); } @@ -168,14 +167,14 @@ sub buildRequest { map { defined $params->{$_} ? $_ . "=" . $params->{$_} : () } keys %$params; - my $url = "$MANA_IP/$resource/$id.json?$params"; + my $url = "$mana_url/$resource/$id.json?$params"; return HTTP::Request->new( GET => $url ); } if ( $type eq 'post' ) { my $content = shift; - my $url = "$MANA_IP/$resource.json"; + my $url = "$mana_url/$resource.json"; my $request = HTTP::Request->new( POST => $url ); my $json = to_json( $content, { utf8 => 1 } ); @@ -196,10 +195,18 @@ sub buildRequest { $param = join '&', map { defined $param->{$_} ? $_ . "=" . $param->{$_} : () } keys %$param; - my $url = "$MANA_IP/$resource/$id.json/increment/$field?$param"; + my $url = "$mana_url/$resource/$id.json/increment/$field?$param"; my $request = HTTP::Request->new( POST => $url ); } } +=head3 manaUrl + +=cut + +sub manaUrl { + return C4::Context->config('mana_config'); +} + 1; --- a/t/db_dependent/Koha/SharedContent.t +++ a/t/db_dependent/Koha/SharedContent.t @@ -23,7 +23,7 @@ use t::lib::TestBuilder; use t::lib::Mocks; use Test::MockModule; use Test::MockObject; -use Test::More tests => 43; +use Test::More tests => 44; use Koha::Database; use Koha::Patrons; use Koha::Subscriptions; @@ -41,7 +41,10 @@ my $want_error = 0; my $post_request = 0; my $query = {}; -$Koha::SharedContent::MANA_IP = 'https://foo.bar'; +t::lib::Mocks::mock_config( 'mana_config', 'https://foo.bar'); + +is(Koha::SharedContent::manaUrl(), 'https://foo.bar', 'Mana URL'); + my $result = Koha::SharedContent::manaGetRequest('report', $query); ok($result->{msg} =~ /Can\'t connect to foo.bar:443$/, 'Unable to connect'); is($result->{code}, 500, 'Code is 500'); --- a/t/db_dependent/Koha/Subscription.t +++ a/t/db_dependent/Koha/Subscription.t @@ -31,7 +31,6 @@ use t::lib::TestBuilder; my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; -my $builder = t::lib::TestBuilder->new; use_ok('Koha::Subscription'); @@ -135,12 +134,11 @@ is( $sub_1->{numberpattern}, my $ref = { 'title' => $biblio_1->{title}, - 'notes' => $sub_1->{notes}, 'sfdescription' => $sub_freq_1->{description}, - 'displayorder' => $sub_freq_1->{displayorder}, 'unit' => $sub_freq_1->{unit}, 'unitsperissue' => $sub_freq_1->{unitsperissue}, 'issuesperunit' => $sub_freq_1->{issuesperunit}, + 'label' => $sub_np_1->{label}, 'sndescription' => $sub_np_1->{description}, 'numberingmethod' => $sub_np_1->{numberingmethod}, 'label1' => $sub_np_1->{label1}, @@ -166,7 +164,7 @@ my $ref = { 'publishercode' => $bi_1->{publishercode} }; -is_deeply( Koha::Subscription::get_sharable_info( $sub_1->{subscriptionid} ), +is_deeply( Koha::Subscription->get_sharable_info( $sub_1->{subscriptionid} ), $ref, "get_sharable_info function is ok" ); $schema->storage->txn_rollback; --