line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SMS::Send::Test;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
SMS::Send::Test - SMS::Send International-Class Testing Driver
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Create a testing sender
|
12
|
|
|
|
|
|
|
my $send = SMS::Send->new( '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 international 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::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
|
3
|
|
|
3
|
|
1690
|
use 5.006;
|
|
3
|
|
|
|
|
11
|
|
51
|
3
|
|
|
3
|
|
16
|
use strict;
|
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
91
|
|
52
|
3
|
|
|
3
|
|
13
|
use SMS::Send::Driver ();
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
574
|
|
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
|
3
|
|
|
3
|
1
|
5
|
my $class = shift;
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Create the object
|
68
|
3
|
|
|
|
|
9
|
my $self = bless {
|
69
|
|
|
|
|
|
|
messages => [ ],
|
70
|
|
|
|
|
|
|
}, $class;
|
71
|
|
|
|
|
|
|
|
72
|
3
|
|
|
|
|
8
|
$self;
|
73
|
|
|
|
|
|
|
}
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub send_sms {
|
76
|
1
|
|
|
1
|
1
|
2
|
my $self = shift;
|
77
|
1
|
|
|
|
|
2
|
my $messages = $self->{messages};
|
78
|
1
|
|
|
|
|
3
|
push @$messages, [ @_ ];
|
79
|
1
|
|
|
|
|
3
|
return 1;
|
80
|
|
|
|
|
|
|
}
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=pod
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 METHODS
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
SMS::Send::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
|
1
|
|
|
1
|
1
|
624
|
my $self = shift;
|
98
|
1
|
|
|
|
|
2
|
return @{$self->{messages}};
|
|
1
|
|
|
|
|
4
|
|
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
|
3
|
|
|
3
|
1
|
1647
|
my $self = shift;
|
113
|
3
|
|
|
|
|
8
|
$self->{messages} = [];
|
114
|
3
|
|
|
|
|
14
|
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
|