From 86239ea6899fd37a32982915302d74f3b8809ada Mon Sep 17 00:00:00 2001 From: Andrew Moore Date: Thu, 3 Jul 2008 14:08:46 -0500 Subject: [PATCH] bug 2275: making SMS::Send module optional 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 --- C4/SMS.pm | 7 ++++++- t/lib/KohaTest/SMS/send_sms.pm | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/C4/SMS.pm b/C4/SMS.pm index 959e407c8d..19f1d852d7 100644 --- 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; diff --git a/t/lib/KohaTest/SMS/send_sms.pm b/t/lib/KohaTest/SMS/send_sms.pm index c23c47f74b..d6bbb64c5b 100644 --- a/t/lib/KohaTest/SMS/send_sms.pm +++ b/t/lib/KohaTest/SMS/send_sms.pm @@ -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', -- 2.20.1