On Tue Aug 21 06:02:54 2007, NPW wrote:
Show quoted text> Seems like one of the attachments (twmc-bug.t) isn't accessible, I'll
> try uploading it again:
Didn't seem to work either. Here it is:
#!/usr/bin/perl -w
use strict;
use CGI;
use Test::More 'no_plan';
my $script_url_path = "/cgi-bin/test";
my $url = "
http://www.server.nowhere$script_url_path";
# this applies the workaround for version 0.1 of Test::WWW::Mechanize::CGI
# hardwired for the sake of demonstration
my $mech_class = 0? #$Test::WWW::Mechanize::CGI::VERSION <= 0.1?
'My::Test::WWW::Mechanize::CGI' : 'Test::WWW::Mechanize::CGI';
use_ok $mech_class;
my $mech = $mech_class->new(autocheck => 1);
$mech->env(SCRIPT_NAME => $script_url_path, # this allows $q->url to work ok
HTTP_USER_AGENT => ref $mech); # stops a warning about an
'uninitialised value' from CGI.pm
my $redirected = 0;
$mech->cgi(sub {
my $q = CGI->new;
if ($q->param('redirected'))
{ print $q->header, $q->start_html, $q->p("hello"), $q->end_html }
else
{ print $q->redirect($q->url."?redirected=1"); $redirected = 1 }
});
# test we get a basic response okay, with no content.yaml
$mech->get_ok($url, "view the admin page with no arguments");
is($redirected, 1, "have been redirected");
my $output = $mech->response->content;
like($output, qr!<p>hello</p>!, "content seems to be correct");