3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Test::More tests => 8;
25 use_ok( 'C4::SMS', qw( driver send_sms ) );
28 my $driver = 'my mock driver';
29 t::lib::Mocks::mock_preference( 'SMSSendDriver', $driver );
30 is( C4::SMS->driver(), $driver, 'driver returns the SMSSendDriver correctly' );
32 t::lib::Mocks::mock_preference( 'SMSSendUsername', 'username' );
33 t::lib::Mocks::mock_preference( 'SMSSendPassword', 'pwd' );
35 my ( $send_sms, $error ) = C4::SMS->send_sms();
36 is( $send_sms, undef, 'send_sms without arguments returns undef' );
38 ($send_sms) = C4::SMS->send_sms(
40 destination => 'my destination',
43 is( $send_sms, undef, 'send_sms without message returns undef' );
45 ($send_sms) = C4::SMS->send_sms(
47 message => 'my message',
50 is( $send_sms, undef, 'send_sms without destination returns undef' );
52 ( $send_sms, $error ) = C4::SMS->send_sms(
54 destination => 'my destination',
55 message => 'my message',
59 is( $send_sms, undef, 'send_sms with an undef driver returns undef' );
60 is( $error, 'SMS_SEND_DRIVER_MISSING', 'Error code returned is SMS_SEND_DRIVER_MISSING' );
62 ( $send_sms, $error ) = C4::SMS->send_sms(
64 destination => '+33123456789',
65 message => 'my message',
69 is( $send_sms, 1, 'send_sms returns 1' );