1Test::Mock::LWP(3)    User Contributed Perl Documentation   Test::Mock::LWP(3)
2
3
4

NAME

6       Test::Mock::LWP - Easy mocking of LWP packages
7

SYNOPSIS

9       Make LWP packages to make testing easier.
10
11           use Test::Mock::LWP;
12
13           # Setup fake response content and code
14           $Mock_response->mock( content => sub { 'foo' } );
15           $Mock_resp->mock( code => sub { 201 } );
16
17           # Validate args passed to request constructor
18           is_deeply $Mock_request->new_args, \@expected_args;
19
20           # Validate request headers
21           is_deeply [ $Mock_req->next_call ],
22                     [ 'header', [ 'Accept', 'text/plain' ] ];
23
24           # Special User Agent Behaviour
25           $Mock_ua->mock( request => sub { die 'foo' } );
26

DESCRIPTION

28       This package arises from duplicating the same code to mock LWP et al in
29       several different modules I've written.  This version is very
30       minimalist, but works for my needs so far.  I'm very open to new
31       suggestions and improvements.
32

EXPORTS

34       The following variables are exported by default:
35
36       $Mock_ua
37           The mock LWP::UserAgent object - a Test::MockObject object
38
39       $Mock_req, $Mock_request
40           The mock HTTP::Request object - a Test::MockObject object
41
42       $Mock_resp, $Mock_response
43           The mock HTTP::Response object - a Test::MockObject object
44

AUTHOR

46       Luke Closs, "<test-mock-lwp at 5thplane.com>"
47

BUGS

49       Please report any bugs or feature requests through the web interface at
50       http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Mock-LWP
51       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Mock-LWP>.  I will
52       be notified, and then you'll automatically be notified of progress on
53       your bug as I make changes.
54

SUPPORT

56       You can find documentation for this module with the perldoc command.
57
58           perldoc Test::Mock::LWP
59
60       You can also look for information at:
61
62       ·   AnnoCPAN: Annotated CPAN documentation
63
64           http://annocpan.org/dist/Test-Mock-LWP
65           <http://annocpan.org/dist/Test-Mock-LWP>
66
67       ·   CPAN Ratings
68
69           http://cpanratings.perl.org/d/Test-Mock-LWP
70           <http://cpanratings.perl.org/d/Test-Mock-LWP>
71
72       ·   RT: CPAN's request tracker
73
74           http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Mock-LWP
75           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Mock-LWP>
76
77       ·   Search CPAN
78
79           http://search.cpan.org/dist/Test-Mock-LWP
80           <http://search.cpan.org/dist/Test-Mock-LWP>
81

ACKNOWLEDGEMENTS

84       Copyright 2006 Luke Closs, all rights reserved.
85
86       This program is free software; you can redistribute it and/or modify it
87       under the same terms as Perl itself.
88
89
90
91perl v5.12.0                      2007-08-08                Test::Mock::LWP(3)
Impressum