View | Details | Raw Unified | Return to bug 17047
Collapse All | Expand All

(-)a/C4/Serials.pm (+1 lines)
Lines 35-40 use Koha::DateUtils; Link Here
35
use Koha::Serial;
35
use Koha::Serial;
36
use Koha::Subscriptions;
36
use Koha::Subscriptions;
37
use Koha::Subscription::Histories;
37
use Koha::Subscription::Histories;
38
use Koha::SharedContent;
38
39
39
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
40
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
40
41
(-)a/Koha/SharedContent.pm (-6 / +13 lines)
Lines 26-33 use Koha::Serials; Link Here
26
use Koha::Reports;
26
use Koha::Reports;
27
use C4::Context;
27
use C4::Context;
28
28
29
our $MANA_IP = C4::Context->config('mana_config');
30
31
=head1 DESCRIPTION
29
=head1 DESCRIPTION
32
30
33
Package for accessing shared content via Mana
31
Package for accessing shared content via Mana
Lines 151-163 sub manaGetRequest { Link Here
151
sub buildRequest {
149
sub buildRequest {
152
    my $type = shift;
150
    my $type = shift;
153
    my $resource = shift;
151
    my $resource = shift;
152
    my $mana_url = manaUrl();
154
153
155
    if ( $type eq 'get' ) {
154
    if ( $type eq 'get' ) {
156
        my $params = shift;
155
        my $params = shift;
157
        $params = join '&',
156
        $params = join '&',
158
            map { defined $params->{$_} ? $_ . "=" . $params->{$_} : () }
157
            map { defined $params->{$_} ? $_ . "=" . $params->{$_} : () }
159
            keys %$params;
158
            keys %$params;
160
        my $url = "$MANA_IP/$resource.json?$params";
159
        my $url = "$mana_url/$resource.json?$params";
161
        return HTTP::Request->new( GET => $url );
160
        return HTTP::Request->new( GET => $url );
162
    }
161
    }
163
162
Lines 168-181 sub buildRequest { Link Here
168
            map { defined $params->{$_} ? $_ . "=" . $params->{$_} : () }
167
            map { defined $params->{$_} ? $_ . "=" . $params->{$_} : () }
169
            keys %$params;
168
            keys %$params;
170
169
171
        my $url = "$MANA_IP/$resource/$id.json?$params";
170
        my $url = "$mana_url/$resource/$id.json?$params";
172
        return HTTP::Request->new( GET => $url );
171
        return HTTP::Request->new( GET => $url );
173
    }
172
    }
174
173
175
    if ( $type eq 'post' ) {
174
    if ( $type eq 'post' ) {
176
        my $content  = shift;
175
        my $content  = shift;
177
176
178
        my $url = "$MANA_IP/$resource.json";
177
        my $url = "$mana_url/$resource.json";
179
        my $request = HTTP::Request->new( POST => $url );
178
        my $request = HTTP::Request->new( POST => $url );
180
179
181
        my $json = to_json( $content, { utf8 => 1 } );
180
        my $json = to_json( $content, { utf8 => 1 } );
Lines 196-205 sub buildRequest { Link Here
196
        $param = join '&',
195
        $param = join '&',
197
           map { defined $param->{$_} ? $_ . "=" . $param->{$_} : () }
196
           map { defined $param->{$_} ? $_ . "=" . $param->{$_} : () }
198
               keys %$param;
197
               keys %$param;
199
        my $url = "$MANA_IP/$resource/$id.json/increment/$field?$param";
198
        my $url = "$mana_url/$resource/$id.json/increment/$field?$param";
200
        my $request = HTTP::Request->new( POST => $url );
199
        my $request = HTTP::Request->new( POST => $url );
201
200
202
    }
201
    }
203
}
202
}
204
203
204
=head3 manaUrl
205
206
=cut
207
208
sub manaUrl {
209
    return C4::Context->config('mana_config');
210
}
211
205
1;
212
1;
(-)a/t/db_dependent/Koha/SharedContent.t (-2 / +5 lines)
Lines 23-29 use t::lib::TestBuilder; Link Here
23
use t::lib::Mocks;
23
use t::lib::Mocks;
24
use Test::MockModule;
24
use Test::MockModule;
25
use Test::MockObject;
25
use Test::MockObject;
26
use Test::More tests => 43;
26
use Test::More tests => 44;
27
use Koha::Database;
27
use Koha::Database;
28
use Koha::Patrons;
28
use Koha::Patrons;
29
use Koha::Subscriptions;
29
use Koha::Subscriptions;
Lines 41-47 my $want_error = 0; Link Here
41
my $post_request = 0;
41
my $post_request = 0;
42
my $query = {};
42
my $query = {};
43
43
44
$Koha::SharedContent::MANA_IP = 'https://foo.bar';
44
t::lib::Mocks::mock_config( 'mana_config', 'https://foo.bar');
45
46
is(Koha::SharedContent::manaUrl(), 'https://foo.bar', 'Mana URL');
47
45
my $result = Koha::SharedContent::manaGetRequest('report', $query);
48
my $result = Koha::SharedContent::manaGetRequest('report', $query);
46
ok($result->{msg} =~ /Can\'t connect to foo.bar:443$/, 'Unable to connect');
49
ok($result->{msg} =~ /Can\'t connect to foo.bar:443$/, 'Unable to connect');
47
is($result->{code}, 500, 'Code is 500');
50
is($result->{code}, 500, 'Code is 500');
(-)a/t/db_dependent/Koha/Subscription.t (-5 / +2 lines)
Lines 31-37 use t::lib::TestBuilder; Link Here
31
31
32
my $schema = Koha::Database->new->schema;
32
my $schema = Koha::Database->new->schema;
33
$schema->storage->txn_begin;
33
$schema->storage->txn_begin;
34
my $builder = t::lib::TestBuilder->new;
35
34
36
use_ok('Koha::Subscription');
35
use_ok('Koha::Subscription');
37
36
Lines 135-146 is( $sub_1->{numberpattern}, Link Here
135
134
136
my $ref = {
135
my $ref = {
137
    'title'           => $biblio_1->{title},
136
    'title'           => $biblio_1->{title},
138
    'notes'           => $sub_1->{notes},
139
    'sfdescription'   => $sub_freq_1->{description},
137
    'sfdescription'   => $sub_freq_1->{description},
140
    'displayorder'    => $sub_freq_1->{displayorder},
141
    'unit'            => $sub_freq_1->{unit},
138
    'unit'            => $sub_freq_1->{unit},
142
    'unitsperissue'   => $sub_freq_1->{unitsperissue},
139
    'unitsperissue'   => $sub_freq_1->{unitsperissue},
143
    'issuesperunit'   => $sub_freq_1->{issuesperunit},
140
    'issuesperunit'   => $sub_freq_1->{issuesperunit},
141
    'label'           => $sub_np_1->{label},
144
    'sndescription'   => $sub_np_1->{description},
142
    'sndescription'   => $sub_np_1->{description},
145
    'numberingmethod' => $sub_np_1->{numberingmethod},
143
    'numberingmethod' => $sub_np_1->{numberingmethod},
146
    'label1'          => $sub_np_1->{label1},
144
    'label1'          => $sub_np_1->{label1},
Lines 166-172 my $ref = { Link Here
166
    'publishercode'   => $bi_1->{publishercode}
164
    'publishercode'   => $bi_1->{publishercode}
167
};
165
};
168
166
169
is_deeply( Koha::Subscription::get_sharable_info( $sub_1->{subscriptionid} ),
167
is_deeply( Koha::Subscription->get_sharable_info( $sub_1->{subscriptionid} ),
170
    $ref, "get_sharable_info function is ok" );
168
    $ref, "get_sharable_info function is ok" );
171
169
172
$schema->storage->txn_rollback;
170
$schema->storage->txn_rollback;
173
- 

Return to bug 17047