Lines 17-26
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 1; |
20 |
use Test::More tests => 2; |
21 |
|
21 |
|
22 |
use Koha::ERM::EUsage::UsageDataProvider; |
22 |
use Koha::ERM::EUsage::UsageDataProvider; |
23 |
use Koha::Database; |
23 |
use Koha::Database; |
|
|
24 |
use Test::MockModule; |
25 |
use Test::MockObject; |
24 |
|
26 |
|
25 |
use t::lib::TestBuilder; |
27 |
use t::lib::TestBuilder; |
26 |
|
28 |
|
Lines 108-110
subtest '_build_url_query' => sub {
Link Here
|
108 |
$schema->storage->txn_rollback; |
110 |
$schema->storage->txn_rollback; |
109 |
|
111 |
|
110 |
}; |
112 |
}; |
111 |
- |
113 |
|
|
|
114 |
subtest 'test_connection() tests' => sub { |
115 |
|
116 |
plan tests => 1; |
117 |
|
118 |
$schema->storage->txn_begin; |
119 |
|
120 |
my $ua = Test::MockModule->new('LWP::UserAgent'); |
121 |
$ua->mock('simple_request', sub { |
122 |
my $response = Test::MockObject->new(); |
123 |
|
124 |
$response->mock('code', sub { |
125 |
return 200; |
126 |
}); |
127 |
$response->mock('is_error', sub { |
128 |
return 0; |
129 |
}); |
130 |
$response->mock('is_redirect', sub { |
131 |
return 0; |
132 |
}); |
133 |
$response->mock('decoded_content', sub { |
134 |
return '{"Description":"COUNTER Usage Reports for Test platform.","ServiceActive":true,"RegistryURL":"https://www.whatever.com"}'; |
135 |
}); |
136 |
$response->{_rc} = 200; |
137 |
return $response; |
138 |
}); |
139 |
|
140 |
my $usage_data_provider = $builder->build_object( |
141 |
{ class => 'Koha::ERM::EUsage::UsageDataProviders', value => { name => 'TestProvider' } } ); |
142 |
|
143 |
is( $usage_data_provider->test_connection, 1); |
144 |
|
145 |
$schema->storage->txn_rollback; |
146 |
}; |