File Coverage

blib/lib/SMS/Send/AU/Test.pm
Criterion Covered Total %
statement 14 21 66.6
branch n/a
condition n/a
subroutine 5 7 71.4
pod 4 4 100.0
total 23 32 71.8


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