| 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 |       IsOverDriveEnabled | 
            
              | 31 |       GetOverDriveToken ) | 
            
              | 32 | ); | 
            
              | 33 |  | 
            
              | 34 | # ---------- Testing IsOverDriveEnabled --------- | 
            
              | 35 |  | 
            
              | 36 | t::lib::Mocks::mock_preference( "OverDriveClientKey",    0 ); | 
            
              | 37 | t::lib::Mocks::mock_preference( "OverDriveClientSecret", 0 ); | 
            
              | 38 |  | 
            
              | 39 | is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' ); | 
            
              | 40 |  | 
            
              | 41 | t::lib::Mocks::mock_preference( "OverDriveClientKey",    0 ); | 
            
              | 42 | t::lib::Mocks::mock_preference( "OverDriveClientSecret", 1 ); | 
            
              | 43 |  | 
            
              | 44 | is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' ); | 
            
              | 45 |  | 
            
              | 46 | t::lib::Mocks::mock_preference( "OverDriveClientKey",    1 ); | 
            
              | 47 | t::lib::Mocks::mock_preference( "OverDriveClientSecret", 0 ); | 
            
              | 48 |  | 
            
              | 49 | is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' ); | 
            
              | 50 |  | 
            
              | 51 | t::lib::Mocks::mock_preference( "OverDriveClientKey",    1 ); | 
            
              | 52 | t::lib::Mocks::mock_preference( "OverDriveClientSecret", 1 ); | 
            
              | 53 |  | 
            
              | 54 | is( IsOverDriveEnabled(), 1, 'IsOverDriveEnabled success' ); |