Bug 17380: [QA Follow-up] Report error to user instead of throwing exception
[koha.git] / t / External / OverDrive.t
blobb6134fad569c020fa4289fd8978cdf95c5885e7c
1 #!/usr/bin/perl
3 # Copyright 2015 BibLibre
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, see <http://www.gnu.org/licenses>.
19 use Modern::Perl;
20 use C4::Context;
21 use t::lib::Mocks qw(mock_preference);
22 use Test::More tests => 6;
24 BEGIN {
25 use_ok('C4::External::OverDrive');
28 can_ok(
29 'C4::External::OverDrive', qw(
30 _request
31 IsOverDriveEnabled
32 GetOverDriveToken )
35 # ---------- Testing IsOverDriveEnabled ---------
37 t::lib::Mocks::mock_preference( "OverDriveClientKey", 0 );
38 t::lib::Mocks::mock_preference( "OverDriveClientSecret", 0 );
40 is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' );
42 t::lib::Mocks::mock_preference( "OverDriveClientKey", 0 );
43 t::lib::Mocks::mock_preference( "OverDriveClientSecret", 1 );
45 is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' );
47 t::lib::Mocks::mock_preference( "OverDriveClientKey", 1 );
48 t::lib::Mocks::mock_preference( "OverDriveClientSecret", 0 );
50 is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' );
52 t::lib::Mocks::mock_preference( "OverDriveClientKey", 1 );
53 t::lib::Mocks::mock_preference( "OverDriveClientSecret", 1 );
55 is( IsOverDriveEnabled(), 1, 'IsOverDriveEnabled success' );