Bug 16166: Improve L1 cache performance and safety
[koha.git] / t / SMS.t
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
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.
9 #
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.
14 #
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>.
17
18 use Modern::Perl;
19
20 use t::lib::Mocks;
21
22 use Test::More tests => 7;
23
24 BEGIN {
25     use_ok('C4::SMS');
26 }
27
28
29 my $driver = 'my mock driver';
30 t::lib::Mocks::mock_preference('SMSSendDriver', $driver);
31 is( C4::SMS->driver(), $driver, 'driver returns the SMSSendDriver correctly' );
32
33 t::lib::Mocks::mock_preference('SMSSendUsername', 'username');
34 t::lib::Mocks::mock_preference('SMSSendPassword', 'pwd');
35
36 my $send_sms = C4::SMS->send_sms();
37 is( $send_sms, undef, 'send_sms without arguments returns undef' );
38
39 $send_sms = C4::SMS->send_sms({
40     destination => 'my destination',
41 });
42 is( $send_sms, undef, 'send_sms without message returns undef' );
43
44 $send_sms = C4::SMS->send_sms({
45     message => 'my message',
46 });
47 is( $send_sms, undef, 'send_sms without destination returns undef' );
48
49 $send_sms = C4::SMS->send_sms({
50     destination => 'my destination',
51     message => 'my message',
52     driver => '',
53 });
54 is( $send_sms, undef, 'send_sms with an undef driver returns undef' );
55
56 $send_sms = C4::SMS->send_sms({
57     destination => '+33123456789',
58     message => 'my message',
59     driver => 'Test',
60 });
61 is( $send_sms, 1, 'send_sms returns 1' );
62
63 1;