Koha/t/External/OverDrive.t
Julian FIOL 64b6df43c9 Bug 14147: Add unit tests to C4::External::OverDrive
This patch test 'IsOverDriveEnabled' subroutine

    TEST PLAN
    ---------
    1. Apply patch
    2. prove -v t/External/OverDrive.t
    -- All tests should run successfully without
    any error or warning

    TEST PLAN OPTIONAL
    ------------------

    Check with bug 13899 to see the coverage of this module.

    Coverage BEFORE this patch :
    Statement  :  47,5%
    Branch     :   0,0%
    Condition  :   0,0%
    Subroutine :  75,0%

    Coverage AFTER this patch :
    Statement  :  49,1%
    Branch     :   0,0%
    Condition  :  33,3%
    Subroutine :  83,3%

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Tests tun, no koha-qa errors

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2015-05-14 11:11:58 -03:00

55 lines
1.7 KiB
Raku
Executable file

#!/usr/bin/perl
# Copyright 2015 BibLibre
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use C4::Context;
use t::lib::Mocks qw(mock_preference);
use Test::More tests => 6;
BEGIN {
use_ok('C4::External::OverDrive');
}
can_ok(
'C4::External::OverDrive', qw(
_request
IsOverDriveEnabled
GetOverDriveToken )
);
# ---------- Testing IsOverDriveEnabled ---------
t::lib::Mocks::mock_preference( "OverDriveClientKey", 0 );
t::lib::Mocks::mock_preference( "OverDriveClientSecret", 0 );
is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' );
t::lib::Mocks::mock_preference( "OverDriveClientKey", 0 );
t::lib::Mocks::mock_preference( "OverDriveClientSecret", 1 );
is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' );
t::lib::Mocks::mock_preference( "OverDriveClientKey", 1 );
t::lib::Mocks::mock_preference( "OverDriveClientSecret", 0 );
is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' );
t::lib::Mocks::mock_preference( "OverDriveClientKey", 1 );
t::lib::Mocks::mock_preference( "OverDriveClientSecret", 1 );
is( IsOverDriveEnabled(), 1, 'IsOverDriveEnabled success' );