1package SMS::Send::AU::Test; 2 3=pod 4 5=head1 NAME 6 7SMS::Send::AU::Test - SMS::Send Regional-Class Testing Driver 8 9=head1 SYNOPSIS 10 11 # Create a testing sender 12 my $send = SMS::Send->new( 'AU-Test' ); 13 14 # Clear the message trap 15 $send->clear; 16 17 # Send a message 18 $send->send_sms( 19 text => 'Hi there', 20 to => '+61 (4) 1234 5678', 21 ); 22 23 # Get the message from the trap 24 my @messages = $send->messages; 25 26=head1 DESCRIPTION 27 28L<SMS::Send> supports two classes of drivers. 29 30An international class named in the format C<SMS::Send::Foo>, which only 31accept international numbers in C<+1 XXX XXXXX> format, and 32regional-context drivers in the format C<SMS::Send::XX::Foo> which will 33also accept a non-leading-plus number in the format applicable within that 34region (in the above case, Australia). 35 36L<SMS::Send::AU::Test> is the testing driver for the regional class of 37drivers. Except for the name, it is otherwise identical to 38L<SMS::Send::Test>. 39 40Its two roles are firstly to always exist (be installed) and secondly 41to act as a "trap" for messages. Messages sent via SMS::Send::AU::Test 42always succeed, and the messages can be recovered for testing after 43sending. 44 45Note that the trap is done on a per-driver-handle basis, and is not 46shared between multiple driver handles. 47 48=cut 49 50use 5.006; 51use strict; 52use SMS::Send::Driver (); 53 54use vars qw{$VERSION @ISA}; 55BEGIN { 56 $VERSION = '0.06'; 57 @ISA = 'SMS::Send::Driver'; 58} 59 60 61 62 63 64##################################################################### 65# Constructor 66 67sub new { 68 my $class = shift; 69 70 # Create the object 71 my $self = bless { 72 messages => [], 73 }, $class; 74 75 $self; 76} 77 78sub send_sms { 79 my $self = shift; 80 my $messages = $self->{messages}; 81 push @$messages, [ @_ ]; 82 return 1; 83} 84 85=pod 86 87=head1 METHODS 88 89SMS::Send::AU::Test inherits all the methods of the parent L<SMS::Send::Driver> 90class, and adds the following. 91 92=head2 messages 93 94The C<messages> method retrieves as a list all of the messages in the 95message trap. 96 97=cut 98 99sub messages { 100 my $self = shift; 101 return @{$self->{messages}}; 102} 103 104=pod 105 106=head2 clear 107 108The C<clear> method clears the message trap. This should be done before 109each chunk of test code to ensure you are starting from a known state. 110 111Returns true as a convenience. 112=cut 113 114sub clear { 115 my $self = shift; 116 $self->{messages} = [ ]; 117 return 1; 118} 119 1201; 121 122=pod 123 124=head1 SUPPORT 125 126Bugs should be reported via the CPAN bug tracker at 127 128L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SMS-Send> 129 130For other issues, contact the author. 131 132=head1 AUTHOR 133 134Adam Kennedy E<lt>adamk@cpan.orgE<gt> 135 136=head1 COPYRIGHT 137 138Copyright 2005 - 2011 Adam Kennedy. 139 140This program is free software; you can redistribute 141it and/or modify it under the same terms as Perl itself. 142 143The full text of the license can be found in the 144LICENSE file included with this module. 145 146=cut 147