Bug 12455: adding unit tests for the module C4/SMS.pm
[koha.git] / t / SMS.t
1 #!/usr/bin/perl
2
3 use Modern::Perl;
4
5 use t::lib::Mocks;
6
7 use Test::More tests => 7;
8
9 BEGIN {
10     use_ok('C4::SMS');
11 }
12
13
14 my $driver = 'my mock driver';
15 t::lib::Mocks::mock_preference('SMSSendDriver', $driver);
16 is( C4::SMS->driver(), $driver, 'driver returns the SMSSendDriver correctly' );
17
18
19 my $send_sms = C4::SMS->send_sms();
20 is( $send_sms, undef, 'send_sms without arguments returns undef' );
21
22 $send_sms = C4::SMS->send_sms({
23     destination => 'my destination',
24 });
25 is( $send_sms, undef, 'send_sms without message returns undef' );
26
27 $send_sms = C4::SMS->send_sms({
28     message => 'my message',
29 });
30 is( $send_sms, undef, 'send_sms without destination returns undef' );
31
32 $send_sms = C4::SMS->send_sms({
33     destination => 'my destination',
34     message => 'my message',
35     driver => '',
36 });
37 is( $send_sms, undef, 'send_sms with an undef driver returns undef' );
38
39 $send_sms = C4::SMS->send_sms({
40     destination => '+33123456789',
41     message => 'my message',
42     driver => 'Test',
43 });
44 is( $send_sms, 1, 'send_sms returns 1' );