Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t
In directory sc8-pr-cvs1:/tmp/cvs-serv23790/t
Modified Files:
02-controller.t
Log Message:
Tests for redirects
Index: 02-controller.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/02-controller.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** 02-controller.t 3 Jan 2003 23:01:17 -0000 1.1.1.1
--- 02-controller.t 24 Jan 2003 09:38:07 -0000 1.2
***************
*** 6,10 ****
use HTTP::Status;
! use Test::More tests => 28;
# get test template files directory included in search path
--- 6,11 ----
use HTTP::Status;
! use Test::More tests => 34;
! use Test::Exception;
# get test template files directory included in search path
***************
*** 73,76 ****
--- 74,79 ----
like($response->content, qr/REQUEST = HTTP::Request/,
'Request object should be passed to template');
+ is($response->header('Pragma'), 'No-Cache',
+ 'Make sure that proxy web interface is not cached');
}
***************
*** 96,98 ****
--- 99,134 ----
like($response->content, qr/parse error.*unexpected token \(ME\)/,
'Verify text of error message');
+ }
+
+ # test redirect()
+ {
+ dies_ok { $CONTROLLER->redirect('xxx') } 'Expecting redirect exception';
+ isa_ok($@, 'HTTP::WebTest::Exception::Redirect',
+ 'Verify exception class');
+ is($@->url, 'xxx', 'Test url property of exception');
+ }
+
+ # try to access page that generates a redirect
+ {
+ local %HTTP::WebTest::Controller::DISPATCH =
+ ( redirect => 'TestRedirect' );
+ # just to disable used only once warning
+ () = %HTTP::WebTest::Controller::DISPATCH;
+ {
+ package TestRedirect;
+ use base qw(HTTP::WebTest::Action);
+
+ sub execute {
+ my $self = shift;
+ my $controller = shift;
+
+ return $controller->redirect('xxx');
+ }
+ }
+ my $request = GET 'http://localhost/webtest/redirect';
+ my $response = $CONTROLLER->execute(action => 'redirect',
+ request => $request);
+ is($response->code, RC_FOUND, 'Expect redirect message');
+ is($response->header('Location'), 'xxx',
+ 'Check if we got correct Location header');
}
|