From 51d881069e5ef79e23c17368dc83e2f49c4eafa1 Mon Sep 17 00:00:00 2001 From: Yohann Dufour Date: Fri, 20 Jun 2014 10:42:13 +0200 Subject: [PATCH] Bug 12455: adding unit tests for the module C4/SMS.pm The module C4/SMS.pm was not tested Test plan: 1/ Execute the command : prove t/SMS.t 2/ The result has to be a success without error or warning : t/SMS.t .. ok All tests successful. Files=1, Tests=7, 1 wallclock secs ( 0.03 usr 0.01 sys + 0.17 cusr 0.02 csys = 0.23 CPU) Result: PASS Signed-off-by: Bernardo Gonzalez Kriegel Replace stub test, all test pass. Removed "use strict/warnings", no need for that with "use Modern::Perl" No koha-qa errors Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- t/SMS.t | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/t/SMS.t b/t/SMS.t index d88633ff75..ab1d3740d6 100755 --- a/t/SMS.t +++ b/t/SMS.t @@ -1,14 +1,44 @@ #!/usr/bin/perl -# -# This Koha test module is a stub! -# Add more tests here!!! -use strict; -use warnings; +use Modern::Perl; -use Test::More tests => 1; +use t::lib::Mocks; + +use Test::More tests => 7; BEGIN { - use_ok('C4::SMS'); + use_ok('C4::SMS'); } + +my $driver = 'my mock driver'; +t::lib::Mocks::mock_preference('SMSSendDriver', $driver); +is( C4::SMS->driver(), $driver, 'driver returns the SMSSendDriver correctly' ); + + +my $send_sms = C4::SMS->send_sms(); +is( $send_sms, undef, 'send_sms without arguments returns undef' ); + +$send_sms = C4::SMS->send_sms({ + destination => 'my destination', +}); +is( $send_sms, undef, 'send_sms without message returns undef' ); + +$send_sms = C4::SMS->send_sms({ + message => 'my message', +}); +is( $send_sms, undef, 'send_sms without destination returns undef' ); + +$send_sms = C4::SMS->send_sms({ + destination => 'my destination', + message => 'my message', + driver => '', +}); +is( $send_sms, undef, 'send_sms with an undef driver returns undef' ); + +$send_sms = C4::SMS->send_sms({ + destination => '+33123456789', + message => 'my message', + driver => 'Test', +}); +is( $send_sms, 1, 'send_sms returns 1' ); -- 2.39.2