Lines 43-51
my $query = {};
Link Here
|
43 |
|
43 |
|
44 |
t::lib::Mocks::mock_config( 'mana_config', 'https://foo.bar'); |
44 |
t::lib::Mocks::mock_config( 'mana_config', 'https://foo.bar'); |
45 |
|
45 |
|
46 |
is(Koha::SharedContent::manaUrl(), 'https://foo.bar', 'Mana URL'); |
46 |
is(Koha::SharedContent::get_sharing_url(), 'https://foo.bar', 'Mana URL'); |
47 |
|
47 |
|
48 |
my $result = Koha::SharedContent::manaGetRequest('report', $query); |
48 |
my $result = Koha::SharedContent::search_entities('report', $query); |
49 |
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'); |
50 |
is($result->{code}, 500, 'Code is 500'); |
50 |
is($result->{code}, 500, 'Code is 500'); |
51 |
|
51 |
|
Lines 56-72
$ua->mock('request', sub {
Link Here
|
56 |
|
56 |
|
57 |
$want_error = 1; |
57 |
$want_error = 1; |
58 |
$query = {query => 'foo', usecomments => 1}; |
58 |
$query = {query => 'foo', usecomments => 1}; |
59 |
$result = Koha::SharedContent::manaGetRequest('report', $query); |
59 |
$result = Koha::SharedContent::search_entities('report', $query); |
60 |
ok($result->{msg} =~ /^Error thrown by decoded_content/, 'Error in decoded_content'); |
60 |
ok($result->{msg} =~ /^Error thrown by decoded_content/, 'Error in decoded_content'); |
61 |
is($result->{code}, 500, 'Code is 500'); |
61 |
is($result->{code}, 500, 'Code is 500'); |
62 |
|
62 |
|
63 |
$want_error = 0; |
63 |
$want_error = 0; |
64 |
$query = {title => 'foo', usecomments => 1}; |
64 |
$query = {title => 'foo', usecomments => 1}; |
65 |
$result = Koha::SharedContent::manaGetRequest('subscription', $query); |
65 |
$result = Koha::SharedContent::search_entities('subscription', $query); |
66 |
is($result->{code}, 200, 'manaGetRequest success'); |
66 |
is($result->{code}, 200, 'search_entities success'); |
67 |
|
67 |
|
68 |
$result = Koha::SharedContent::manaGetRequestWithId('subscription', 23); |
68 |
$result = Koha::SharedContent::get_entity_by_id('subscription', 23); |
69 |
is($result->{code}, 200, 'manaGetRequestWithId success'); |
69 |
is($result->{code}, 200, 'get_entity_by_id success'); |
70 |
|
70 |
|
71 |
my $params = { |
71 |
my $params = { |
72 |
title => 'The English historical review', |
72 |
title => 'The English historical review', |
Lines 76-82
my $params = {
Link Here
|
76 |
}; |
76 |
}; |
77 |
|
77 |
|
78 |
# Search a subscription. |
78 |
# Search a subscription. |
79 |
my $request = Koha::SharedContent::buildRequest('get', 'subscription', $params); |
79 |
my $request = Koha::SharedContent::build_request('get', 'subscription', $params); |
80 |
is($request->method, 'GET', 'Get subscription - Method is get'); |
80 |
is($request->method, 'GET', 'Get subscription - Method is get'); |
81 |
|
81 |
|
82 |
my %query = $request->uri->query_form; |
82 |
my %query = $request->uri->query_form; |
Lines 88-94
is($query{publishercode}, 'Longman', 'Check publisher');
Link Here
|
88 |
is($request->uri->path, '/subscription.json', 'Path is subscription'); |
88 |
is($request->uri->path, '/subscription.json', 'Path is subscription'); |
89 |
|
89 |
|
90 |
# Get a report by id. |
90 |
# Get a report by id. |
91 |
$request = Koha::SharedContent::buildRequest('getwithid', 'report', 26); |
91 |
$request = Koha::SharedContent::build_request('getwithid', 'report', 26); |
92 |
is($request->method, 'GET', 'Get with id - Method is get'); |
92 |
is($request->method, 'GET', 'Get with id - Method is get'); |
93 |
|
93 |
|
94 |
is($request->uri->path, '/report/26.json', 'Path is report/26.json'); |
94 |
is($request->uri->path, '/report/26.json', 'Path is report/26.json'); |
Lines 105-111
my $content = {
Link Here
|
105 |
'type' => undef |
105 |
'type' => undef |
106 |
}; |
106 |
}; |
107 |
|
107 |
|
108 |
$request = Koha::SharedContent::buildRequest('post', 'report', $content); |
108 |
$request = Koha::SharedContent::build_request('post', 'report', $content); |
109 |
is($request->method, 'POST', 'Share report - Method is post'); |
109 |
is($request->method, 'POST', 'Share report - Method is post'); |
110 |
|
110 |
|
111 |
is($request->uri->path, '/report.json', 'Path is report.json'); |
111 |
is($request->uri->path, '/report.json', 'Path is report.json'); |
Lines 163-175
C4::Context->set_userenv(0,0,0,
Link Here
|
163 |
t::lib::Mocks::mock_preference('language', 'en'); |
163 |
t::lib::Mocks::mock_preference('language', 'en'); |
164 |
|
164 |
|
165 |
$post_request = 1; |
165 |
$post_request = 1; |
166 |
$result = Koha::SharedContent::manaPostRequest('en', $loggedinuser->{borrowernumber}, $subscription->{subscriptionid}, 'subscription'); |
166 |
$result = Koha::SharedContent::send_entity('en', $loggedinuser->{borrowernumber}, $subscription->{subscriptionid}, 'subscription'); |
167 |
is($result->{code}, 200, 'manaPostRequest success'); |
167 |
is($result->{code}, 200, 'send_entity success'); |
168 |
|
168 |
|
169 |
my $s = Koha::Subscriptions->find($subscription->{subscriptionid}); |
169 |
my $s = Koha::Subscriptions->find($subscription->{subscriptionid}); |
170 |
is($s->mana_id, 5, 'Mana id is set'); |
170 |
is($s->mana_id, 5, 'Mana id is set'); |
171 |
|
171 |
|
172 |
my $data = Koha::SharedContent::prepareSharedData( |
172 |
my $data = Koha::SharedContent::prepare_entity_data( |
173 |
'', |
173 |
'', |
174 |
$loggedinuser->{borrowernumber}, |
174 |
$loggedinuser->{borrowernumber}, |
175 |
$subscription->{subscriptionid}, |
175 |
$subscription->{subscriptionid}, |
Lines 235-241
sub mock_response {
Link Here
|
235 |
} |
235 |
} |
236 |
|
236 |
|
237 |
# Increment request. |
237 |
# Increment request. |
238 |
$request = Koha::SharedContent::buildRequest('increment', |
238 |
$request = Koha::SharedContent::build_request('increment', |
239 |
'subscription', |
239 |
'subscription', |
240 |
12, |
240 |
12, |
241 |
'foo'); |
241 |
'foo'); |
242 |
- |
|
|