From 0962836de1e1e8044cfafb828d3facd335f764c0 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 --- t/SMS.t | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/t/SMS.t b/t/SMS.t index d88633f..72b1cc3 100755 --- a/t/SMS.t +++ b/t/SMS.t @@ -1,14 +1,46 @@ #!/usr/bin/perl -# -# This Koha test module is a stub! -# Add more tests here!!! +use Modern::Perl; use strict; use warnings; -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' ); -- 1.9.1