diff options
author | Marius Halden <marius.h@lden.org> | 2016-05-28 13:49:00 +0200 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2016-05-28 13:49:00 +0200 |
commit | 6791ce86ae15adbded24bd814a78cc0e87f404fa (patch) | |
tree | 99af5da31e4db091350a09bcdee913c99abc2fc3 /t/Mock/Twitter.pm | |
parent | 6c1118dbf2c4b15bcfcd77600d36f2389428c75e (diff) | |
parent | 89b0efeb94631c4c31ce33e7f98297e754dd226d (diff) |
Merge tag 'v1.8.2' into fiksgatami-dev
Diffstat (limited to 't/Mock/Twitter.pm')
-rw-r--r-- | t/Mock/Twitter.pm | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/t/Mock/Twitter.pm b/t/Mock/Twitter.pm new file mode 100644 index 000000000..930895e28 --- /dev/null +++ b/t/Mock/Twitter.pm @@ -0,0 +1,43 @@ +package t::Mock::Twitter; + +use JSON::MaybeXS; +use Web::Simple; +use MooX::Types::MooseLike::Base qw(:all); + +has json => ( + is => 'lazy', + default => sub { + JSON->new->pretty->allow_blessed->convert_blessed; + }, +); + +sub dispatch_request { + my $self = shift; + + sub (GET + /oauth/authenticate + ?*) { + my ($self) = @_; + return [ 200, [ 'Content-Type' => 'text/html' ], [ 'TwitteB login page' ] ]; + }, + + sub (GET + /oauth/access_token + ?*) { + my ($self) = @_; + return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'oauth_token=access_token&oauth_token_secret=secret' ] ]; + }, + + sub (GET + /oauth/request_token + ?*) { + my ($self) = @_; + return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'oauth_token=request-token&oauth_token_secret=secret&oauth_callback_confirmed=true' ] ]; + }, + + sub (GET + /1.1/account/verify_credentials.json + ?*) { + my ($self) = @_; + my $data = { + id => '987654321', + name => 'Fiona Tester', + }; + my $json = $self->json->encode($data); + return [ 200, [ 'Content-Type' => 'text/html' ], [ $json ] ]; + }, +} + +__PACKAGE__->run_if_script; |