Bug 8630: (follow-up) Make Adlibris cover show on OPAC overdues tab
[koha.git] / t / Koha_ExternalContent_RecordedBooks.t
blob7fdbfaa03274ee879f31c0beb7e3e3199e02126b
1 #!/usr/bin/env perl
3 use Modern::Perl;
5 use t::lib::Mocks;
6 use Test::More;
7 use Test::MockModule;
9 use Module::Load::Conditional qw( can_load );
11 plan tests => 3;
13 SKIP: {
14 skip "cannot find WebService::ILS::RecordedBooks::Partner", 3
15 unless can_load( modules => { 'WebService::ILS::RecordedBooks::Patron' => undef } );
17 use_ok('Koha::ExternalContent::RecordedBooks');
19 t::lib::Mocks::mock_preference('SessionStorage','tmp');
21 t::lib::Mocks::mock_preference('RecordedBooksLibraryID', 'DUMMY');
22 t::lib::Mocks::mock_preference('RecordedBooksClientSecret', 'DUMMY');
23 t::lib::Mocks::mock_preference('RecordedBooksDomain', 'DUMMY');
25 my $client = Koha::ExternalContent::RecordedBooks->new();
26 local $@;
27 eval { $client->search({query => "art"}) };
29 ok($@ =~ /This endpoint can be called by authorized trusted app or trusted partner only/, "Invalid RecordedBooks partner credentials");
31 SKIP: {
32 skip "no RecordedBooks partner credentials", 1 unless $ENV{RECORDEDBOOKS_TEST_LIBRARY_ID};
34 t::lib::Mocks::mock_preference('RecordedBooksLibraryID', $ENV{RECORDEDBOOKS_TEST_LIBRARY_ID});
35 t::lib::Mocks::mock_preference('RecordedBooksClientSecret', $ENV{RECORDEDBOOKS_TEST_CLIENT_SECRET});
36 t::lib::Mocks::mock_preference('RecordedBooksDomain', $ENV{RECORDEDBOOKS_TEST_DOMAIN});
38 $client = Koha::ExternalContent::RecordedBooks->new();
39 my $res = $client->search({query => "art"});
40 ok($res->{items}, "search")