bug 2275: making SMS::Send module optional
authorAndrew Moore <andrew.moore@liblime.com>
Thu, 3 Jul 2008 19:08:46 +0000 (14:08 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Fri, 4 Jul 2008 14:22:27 +0000 (09:22 -0500)
I wrapped the use of the SMS::Send module in an eval to make failures graceful if it
is not present.
I also fixed an error with the number of tests in the SMS::Send tests.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/SMS.pm
t/lib/KohaTest/SMS/send_sms.pm

index 959e407..19f1d85 100644 (file)
--- a/C4/SMS.pm
+++ b/C4/SMS.pm
@@ -34,7 +34,6 @@ use strict;
 use warnings;
 
 use C4::Context;
-use SMS::Send;
 
 use vars qw( $VERSION );
 
@@ -67,6 +66,12 @@ sub send_sms {
         return unless defined $params->{ $required_parameter };
     }
 
+    eval { require SMS::Send; };
+    if ( $@ ) {
+        # we apparently don't have SMS::Send. Return a failure.
+        return;
+    }
+
     # This allows the user to override the driver. See SMS::Send::Test
     my $driver = exists $params->{'driver'} ? $params->{'driver'} : $self->driver();
     return unless $driver;
index c23c47f..d6bbb64 100644 (file)
@@ -10,7 +10,7 @@ use C4::SMS;
 sub testing_class { 'C4::SMS' };
 
 
-sub send_a_message : Test( 2 ) {
+sub send_a_message : Test( 1 ) {
     my $self = shift;
 
     my $success = C4::SMS->send_sms( { destination => '+1 212-555-1111',