Bug 12455: adding unit tests for the module C4/SMS.pm
authorYohann Dufour <dufour.yohann@gmail.com>
Fri, 20 Jun 2014 08:42:13 +0000 (10:42 +0200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Mon, 30 Jun 2014 15:24:07 +0000 (12:24 -0300)
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 <bgkriegel@gmail.com>
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 <Katrin.Fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
t/SMS.t

diff --git a/t/SMS.t b/t/SMS.t
index d88633f..ab1d374 100755 (executable)
--- 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' );