]> Dogcows Code - chaz/p5-HTTP-AnyUA/blob - t/lib/MockBackend.pm
Version 0.900
[chaz/p5-HTTP-AnyUA] / t / lib / MockBackend.pm
1 package MockBackend;
2 # ABSTRACT: A backend for testing HTTP::AnyUA
3
4 use warnings;
5 use strict;
6
7 use parent 'HTTP::AnyUA::Backend';
8
9
10 =method response
11
12 $response = $backend->response;
13 $response = $backend->response($response);
14
15 Get and set the response hashref or L<Future> that this backend will always respond with.
16
17 =cut
18
19 sub response { @_ == 2 ? $_[0]->{response} = pop : $_[0]->{response} }
20
21 =method requests
22
23 @requests = $backend->requests;
24
25 Get the requests the backend has handled so far.
26
27 =cut
28
29 sub requests { @{$_[0]->{requests} || []} }
30
31 sub request {
32 my $self = shift;
33
34 push @{$self->{requests} ||= []}, [@_];
35
36 return $self->response || {
37 success => '',
38 status => 599,
39 reason => 'Internal Exception',
40 content => "No response mocked.\n",
41 };
42 }
43
44
45 1;
This page took 0.031043 seconds and 4 git commands to generate.