3 package Test::WWW::Mechanize::CGI;
7 use base 'Test::WWW::Mechanize';
10 use HTTP::Request::AsCGI;
24 my ( $self, $request ) = @_;
26 if ( $self->cookie_jar ) {
27 $self->cookie_jar->add_cookie_header($request);
30 my $c = HTTP::Request::AsCGI->new($request)->setup;
32 eval { $self->cgi->() };
37 $response = HTTP::Response->new(500);
38 $response->date( time() );
39 $response->content( $response->error_as_HTML );
42 $response = $c->restore->response;
45 $response->header( 'Content-Base', $request->uri );
46 $response->request($request);
48 if ( $self->cookie_jar ) {
49 $self->cookie_jar->extract_cookies($response);
61 use Test::More tests => 3;
63 my $mech = Test::WWW::Mechanize::CGI->new;
69 $q->start_html('Hello World'),
70 $q->h1('Hello World'),
74 $mech->get_ok('http://localhost/');
75 $mech->title_is('Hello World');
76 $mech->content_contains('Hello World');