SMS::Send::AU::Test - SMS::Send Regional-Class Testing Driver


SMS-Send documentation Contained in the SMS-Send distribution.

Index


Code Index:

NAME

Top

SMS::Send::AU::Test - SMS::Send Regional-Class Testing Driver

SYNOPSIS

Top

  # Create a testing sender
  my $send = SMS::Send->new( 'AU-Test' );

  # Clear the message trap
  $send->clear;

  # Send a message
  $send->send_sms(
  	text => 'Hi there',
  	to   => '+61 (4) 1234 5678',
  	);

  # Get the message from the trap
  my @messages = $send->messages;

DESCRIPTION

Top

SMS::Send supports two classes of drivers.

An international class named in the format SMS::Send::Foo, which only accept international numbers in +1 XXX XXXXX format, and regional-context drivers in the format SMS::Send::XX::Foo which will also accept a non-leading-plus number in the format applicable within that region (in the above case, Australia).

SMS::Send::AU::Test is the testing driver for the regional class of drivers. Except for the name, it is otherwise identical to SMS::Send::Test.

Its two roles are firstly to always exist (be installed) and secondly to act as a "trap" for messages. Messages sent via SMS::Send::AU::Test always succeed, and the messages can be recovered for testing after sending.

Note that the trap is done on a per-driver-handle basis, and is not shared between multiple driver handles.

METHODS

Top

SMS::Send::AU::Test inherits all the methods of the parent SMS::Send::Driver class, and adds the following.

messages

The messages method retrieves as a list all of the messages in the message trap.

clear

The clear method clears the message trap. This should be done before each chunk of test code to ensure you are starting from a known state.

Returns true as a convenience. =cut

SUPPORT

Top

Bugs should be reported via the CPAN bug tracker at

http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SMS-Send

For other issues, contact the author.

AUTHOR

Top

Adam Kennedy <adamk@cpan.org>, http://ali.as/

COPYRIGHT

Top


SMS-Send documentation Contained in the SMS-Send distribution.
package SMS::Send::AU::Test;

use strict;
use base 'SMS::Send::Driver';

use vars qw{$VERSION};
BEGIN {
	$VERSION = '0.05';
}





#####################################################################
# Constructor

sub new {
	my $class = shift;

	# Create the object
	my $self = bless {
		messages => [],
		}, $class;

	$self;
}

sub send_sms {
	my $self     = shift;
	my $messages = $self->{messages};
	push @$messages, [ @_ ];
	1;
}

sub messages {
	my $self = shift;
	return @{$self->{messages}};
}

sub clear {
	my $self = shift;
	$self->{messages} = [];
	1;
}

1;