aboutsummaryrefslogtreecommitdiffstats
path: root/t/Mock/Twilio.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-09-30 22:14:48 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-09-30 22:14:48 +0100
commit8e9cd7cdb0a0f0fe591c2ecc25ae480fa0a5f799 (patch)
treede46361b23538b6ba9644898a9f5a55b4aeed9e4 /t/Mock/Twilio.pm
parenta369e1c1a178697d0f92cf82c5bdb23c1883925e (diff)
parent83825ebf47cfd40ac649853347c8352944a3d32a (diff)
Merge branch 'phone-number-work'
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;