Lines 118-146
subtest 'test_connection() tests' => sub {
Link Here
|
118 |
$schema->storage->txn_begin; |
118 |
$schema->storage->txn_begin; |
119 |
|
119 |
|
120 |
my $ua = Test::MockModule->new('LWP::UserAgent'); |
120 |
my $ua = Test::MockModule->new('LWP::UserAgent'); |
121 |
$ua->mock('simple_request', sub { |
121 |
$ua->mock( |
|
|
122 |
'simple_request', |
123 |
sub { |
122 |
my $response = Test::MockObject->new(); |
124 |
my $response = Test::MockObject->new(); |
123 |
|
125 |
|
124 |
$response->mock('code', sub { |
126 |
$response->mock( |
125 |
return 200; |
127 |
'code', |
126 |
}); |
128 |
sub { |
127 |
$response->mock('is_error', sub { |
129 |
return 200; |
128 |
return 0; |
130 |
} |
129 |
}); |
131 |
); |
130 |
$response->mock('is_redirect', sub { |
132 |
$response->mock( |
131 |
return 0; |
133 |
'is_error', |
132 |
}); |
134 |
sub { |
133 |
$response->mock('decoded_content', sub { |
135 |
return 0; |
134 |
return '{"Description":"COUNTER Usage Reports for Test platform.","ServiceActive":true,"RegistryURL":"https://www.whatever.com"}'; |
136 |
} |
135 |
}); |
137 |
); |
|
|
138 |
$response->mock( |
139 |
'is_redirect', |
140 |
sub { |
141 |
return 0; |
142 |
} |
143 |
); |
144 |
$response->mock( |
145 |
'decoded_content', |
146 |
sub { |
147 |
return |
148 |
'{"Description":"COUNTER Usage Reports for Test platform.","ServiceActive":true,"RegistryURL":"https://www.whatever.com"}'; |
149 |
} |
150 |
); |
136 |
$response->{_rc} = 200; |
151 |
$response->{_rc} = 200; |
137 |
return $response; |
152 |
return $response; |
138 |
}); |
153 |
} |
|
|
154 |
); |
139 |
|
155 |
|
140 |
my $usage_data_provider = $builder->build_object( |
156 |
my $usage_data_provider = $builder->build_object( |
141 |
{ class => 'Koha::ERM::EUsage::UsageDataProviders', value => { name => 'TestProvider' } } ); |
157 |
{ class => 'Koha::ERM::EUsage::UsageDataProviders', value => { name => 'TestProvider' } } ); |
142 |
|
158 |
|
143 |
is( $usage_data_provider->test_connection, 1); |
159 |
is( $usage_data_provider->test_connection, 1 ); |
144 |
|
160 |
|
145 |
$schema->storage->txn_rollback; |
161 |
$schema->storage->txn_rollback; |
146 |
}; |
162 |
}; |
147 |
- |
|
|