rename C::E::HTTP.pm to C::E::LWP.pm
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / Test.pm
CommitLineData
e646f111 1package Catalyst::Engine::Test;
2
3use strict;
6f4e1683 4use base 'Catalyst::Engine::LWP';
e646f111 5
6=head1 NAME
7
8Catalyst::Engine::Test - Catalyst Test Engine
9
10=head1 SYNOPSIS
11
c9afa5fc 12A script using the Catalyst::Engine::Test module might look like:
13
14 #!/usr/bin/perl -w
15
16 BEGIN {
17 $ENV{CATALYST_ENGINE} = 'Test';
18 }
19
20 use strict;
21 use lib '/path/to/MyApp/lib';
22 use MyApp;
23
24 MyApp->run('/a/path');
e646f111 25
26=head1 DESCRIPTION
27
28This is the Catalyst engine specialized for testing.
29
30=head1 OVERLOADED METHODS
31
6f4e1683 32This class overloads some methods from C<Catalyst::Engine::LWP>.
e646f111 33
34=over 4
35
36=item $c->run
37
38=cut
39
40sub run {
41 my $class = shift;
42 my $request = shift || '/';
43
44 unless ( ref $request ) {
45374ac6 45
46 my $uri = ( $request =~ m/http/i )
47 ? URI->new($request)
48 : URI->new( 'http://localhost' . $request );
49
50 $request = $uri->canonical;
e646f111 51 }
45374ac6 52
e646f111 53 unless ( ref $request eq 'HTTP::Request' ) {
54 $request = HTTP::Request->new( 'GET', $request );
55 }
56
6f4e1683 57 my $lwp = Catalyst::Engine::LWP::HTTP->new(
45374ac6 58 request => $request,
59 address => '127.0.0.1',
60 hostname => 'localhost'
61 );
e646f111 62
6f4e1683 63 $class->handler($lwp);
e646f111 64
6f4e1683 65 return $lwp->response;
e646f111 66}
67
68=back
69
70=head1 SEE ALSO
71
72L<Catalyst>.
73
74=head1 AUTHOR
75
76Sebastian Riedel, C<sri@cpan.org>
77Christian Hansen, C<ch@ngmedia.com>
78
79=head1 COPYRIGHT
80
81This program is free software, you can redistribute it and/or modify it under
82the same terms as Perl itself.
83
84=cut
85
861;