|
Line 0
Link Here
|
|
|
1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
# Copyright 2015 BibLibre |
| 4 |
# |
| 5 |
# This file is part of Koha. |
| 6 |
# |
| 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. |
| 11 |
# |
| 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. |
| 15 |
# |
| 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>. |
| 18 |
|
| 19 |
use Modern::Perl; |
| 20 |
use C4::Context; |
| 21 |
use t::lib::Mocks qw(mock_preference); |
| 22 |
use Test::More tests => 6; |
| 23 |
|
| 24 |
BEGIN { |
| 25 |
use_ok('C4::External::OverDrive'); |
| 26 |
} |
| 27 |
|
| 28 |
can_ok( |
| 29 |
'C4::External::OverDrive', qw( |
| 30 |
_request |
| 31 |
IsOverDriveEnabled |
| 32 |
GetOverDriveToken ) |
| 33 |
); |
| 34 |
|
| 35 |
# ---------- Testing IsOverDriveEnabled --------- |
| 36 |
|
| 37 |
t::lib::Mocks::mock_preference( "OverDriveClientKey", 0 ); |
| 38 |
t::lib::Mocks::mock_preference( "OverDriveClientSecret", 0 ); |
| 39 |
|
| 40 |
is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' ); |
| 41 |
|
| 42 |
t::lib::Mocks::mock_preference( "OverDriveClientKey", 0 ); |
| 43 |
t::lib::Mocks::mock_preference( "OverDriveClientSecret", 1 ); |
| 44 |
|
| 45 |
is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' ); |
| 46 |
|
| 47 |
t::lib::Mocks::mock_preference( "OverDriveClientKey", 1 ); |
| 48 |
t::lib::Mocks::mock_preference( "OverDriveClientSecret", 0 ); |
| 49 |
|
| 50 |
is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' ); |
| 51 |
|
| 52 |
t::lib::Mocks::mock_preference( "OverDriveClientKey", 1 ); |
| 53 |
t::lib::Mocks::mock_preference( "OverDriveClientSecret", 1 ); |
| 54 |
|
| 55 |
is( IsOverDriveEnabled(), 1, 'IsOverDriveEnabled success' ); |