aboutsummaryrefslogtreecommitdiffstats
path: root/t/Mock/Twilio.pm
diff options
context:
space:
mode:
Diffstat (limited to 't/Mock/Twilio.pm')
-rw-r--r--t/Mock/Twilio.pm28
1 files changed, 28 insertions, 0 deletions
diff --git a/t/Mock/Twilio.pm b/t/Mock/Twilio.pm
new file mode 100644
index 000000000..eaad30b76
--- /dev/null
+++ b/t/Mock/Twilio.pm
@@ -0,0 +1,28 @@
+package t::Mock::Twilio;
+
+use Web::Simple;
+
+has texts => (
+ is => 'ro',
+ default => sub { [] },
+);
+
+sub get_text_code {
+ my $self = shift;
+ my $text = shift @{$self->texts};
+ return unless $text;
+ my ($code) = $text->{Body} =~ /(\d+)/;
+ return $code;
+}
+
+sub dispatch_request {
+ my $self = shift;
+
+ sub (POST + /2010-04-01/Accounts/*/Messages.json + %*) {
+ my ($self, $sid, $data) = @_;
+ push @{$self->texts}, $data;
+ return [ 200, [ 'Content-Type' => 'application/json' ], [ '{}' ] ];
+ },
+}
+
+__PACKAGE__->run_if_script;