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

(-)a/t/db_dependent/Koha/ERM/EUsage/UsageDataProvider.t (-2 / +37 lines)
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 73-75 subtest '_build_url_query' => sub { Link Here
73
    $schema->storage->txn_rollback;
75
    $schema->storage->txn_rollback;
74
76
75
};
77
};
76
- 
78
79
subtest 'test_connection() tests' => sub {
80
81
    plan tests => 1;
82
83
    $schema->storage->txn_begin;
84
85
    my $ua = Test::MockModule->new('LWP::UserAgent');
86
    $ua->mock('simple_request', sub {
87
            my $response = Test::MockObject->new();
88
89
            $response->mock('code', sub {
90
                return 200;
91
            });
92
            $response->mock('is_error', sub {
93
                return 0;
94
            });
95
            $response->mock('is_redirect', sub {
96
                return 0;
97
            });
98
            $response->mock('decoded_content', sub {
99
                return '{"Description":"COUNTER Usage Reports for Test platform.","ServiceActive":true,"RegistryURL":"https://www.whatever.com"}';
100
            });
101
            $response->{_rc} = 200;
102
            return $response;
103
    });
104
105
    my $usage_data_provider = $builder->build_object(
106
        { class => 'Koha::ERM::EUsage::UsageDataProviders', value => { name => 'TestProvider' } } );
107
108
    is( $usage_data_provider->test_connection, 1);
109
110
    $schema->storage->txn_rollback;
111
};

Return to bug 37810