|
Lines 19-62
use Modern::Perl;
Link Here
|
| 19 |
|
19 |
|
| 20 |
use t::lib::Mocks; |
20 |
use t::lib::Mocks; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 7; |
22 |
use Test::More tests => 8; |
| 23 |
|
23 |
|
| 24 |
BEGIN { |
24 |
BEGIN { |
| 25 |
use_ok('C4::SMS', qw( driver send_sms )); |
25 |
use_ok( 'C4::SMS', qw( driver send_sms ) ); |
| 26 |
} |
26 |
} |
| 27 |
|
27 |
|
| 28 |
|
|
|
| 29 |
my $driver = 'my mock driver'; |
28 |
my $driver = 'my mock driver'; |
| 30 |
t::lib::Mocks::mock_preference('SMSSendDriver', $driver); |
29 |
t::lib::Mocks::mock_preference( 'SMSSendDriver', $driver ); |
| 31 |
is( C4::SMS->driver(), $driver, 'driver returns the SMSSendDriver correctly' ); |
30 |
is( C4::SMS->driver(), $driver, 'driver returns the SMSSendDriver correctly' ); |
| 32 |
|
31 |
|
| 33 |
t::lib::Mocks::mock_preference('SMSSendUsername', 'username'); |
32 |
t::lib::Mocks::mock_preference( 'SMSSendUsername', 'username' ); |
| 34 |
t::lib::Mocks::mock_preference('SMSSendPassword', 'pwd'); |
33 |
t::lib::Mocks::mock_preference( 'SMSSendPassword', 'pwd' ); |
| 35 |
|
34 |
|
| 36 |
my $send_sms = C4::SMS->send_sms(); |
35 |
my ( $send_sms, $error ) = C4::SMS->send_sms(); |
| 37 |
is( $send_sms, undef, 'send_sms without arguments returns undef' ); |
36 |
is( $send_sms, undef, 'send_sms without arguments returns undef' ); |
| 38 |
|
37 |
|
| 39 |
$send_sms = C4::SMS->send_sms({ |
38 |
($send_sms) = C4::SMS->send_sms( |
| 40 |
destination => 'my destination', |
39 |
{ |
| 41 |
}); |
40 |
destination => 'my destination', |
|
|
41 |
} |
| 42 |
); |
| 42 |
is( $send_sms, undef, 'send_sms without message returns undef' ); |
43 |
is( $send_sms, undef, 'send_sms without message returns undef' ); |
| 43 |
|
44 |
|
| 44 |
$send_sms = C4::SMS->send_sms({ |
45 |
($send_sms) = C4::SMS->send_sms( |
| 45 |
message => 'my message', |
46 |
{ |
| 46 |
}); |
47 |
message => 'my message', |
|
|
48 |
} |
| 49 |
); |
| 47 |
is( $send_sms, undef, 'send_sms without destination returns undef' ); |
50 |
is( $send_sms, undef, 'send_sms without destination returns undef' ); |
| 48 |
|
51 |
|
| 49 |
$send_sms = C4::SMS->send_sms({ |
52 |
( $send_sms, $error ) = C4::SMS->send_sms( |
| 50 |
destination => 'my destination', |
53 |
{ |
| 51 |
message => 'my message', |
54 |
destination => 'my destination', |
| 52 |
driver => '', |
55 |
message => 'my message', |
| 53 |
}); |
56 |
driver => '', |
| 54 |
is( $send_sms, undef, 'send_sms with an undef driver returns undef' ); |
57 |
} |
| 55 |
|
58 |
); |
| 56 |
$send_sms = C4::SMS->send_sms({ |
59 |
is( $send_sms, undef, 'send_sms with an undef driver returns undef' ); |
| 57 |
destination => '+33123456789', |
60 |
is( $error, 'SMS_SEND_DRIVER_MISSING', 'Error code returned is SMS_SEND_DRIVER_MISSING' ); |
| 58 |
message => 'my message', |
61 |
|
| 59 |
driver => 'Test', |
62 |
( $send_sms, $error ) = C4::SMS->send_sms( |
| 60 |
}); |
63 |
{ |
|
|
64 |
destination => '+33123456789', |
| 65 |
message => 'my message', |
| 66 |
driver => 'Test', |
| 67 |
} |
| 68 |
); |
| 61 |
is( $send_sms, 1, 'send_sms returns 1' ); |
69 |
is( $send_sms, 1, 'send_sms returns 1' ); |
| 62 |
|
70 |
|
| 63 |
- |
|
|