X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Flib%2FTestApp%2FController%2FRoot.pm;h=8541e2ec67395cdbef9c0d674b637d023210a902;hp=afdf6db853a0aa79dfaf460179b4daa0be6a0e1b;hb=82010ea176741c7a4f2baf3f6f27377b1d9f6b15;hpb=a202886b47ea577ff9e29c18214a7c02cfd8b9e3
diff --git a/t/lib/TestApp/Controller/Root.pm b/t/lib/TestApp/Controller/Root.pm
index afdf6db..8541e2e 100644
--- a/t/lib/TestApp/Controller/Root.pm
+++ b/t/lib/TestApp/Controller/Root.pm
@@ -1,6 +1,8 @@
package TestApp::Controller::Root;
-
+use strict;
+use warnings;
use base 'Catalyst::Controller';
+use utf8;
__PACKAGE__->config->{namespace} = '';
@@ -13,11 +15,14 @@ sub zero : Path('0') {
$c->forward('TestApp::View::Dump::Request');
}
-sub localregex : LocalRegex('^localregex$') {
- my ( $self, $c ) = @_;
- $c->res->header( 'X-Test-Class' => ref($self) );
- $c->response->content_type('text/plain; charset=utf-8');
- $c->forward('TestApp::View::Dump::Request');
+sub zerobody : Local {
+ my ($self, $c) = @_;
+ $c->res->body('0');
+}
+
+sub emptybody : Local {
+ my ($self, $c) = @_;
+ $c->res->body('');
}
sub index : Private {
@@ -45,7 +50,97 @@ sub loop_test : Local {
sub recursion_test : Local {
my ( $self, $c ) = @_;
+ no warnings 'recursion';
$c->forward( 'recursion_test' );
}
+sub base_href_test : Local {
+ my ( $self, $c ) = @_;
+
+ my $body = <<"EndOfBody";
+
+
+
+
+
+
+
+EndOfBody
+
+ $c->response->body($body);
+}
+
+sub body_semipredicate : Local {
+ my ($self, $c) = @_;
+ $c->res->body; # Old code tests length($c->res->body), which causes the value to be built (undef), which causes the predicate
+ $c->res->status( $c->res->has_body ? 500 : 200 ); # to return the wrong thing, resulting in a 500.
+ $c->res->body('Body');
+}
+
+
+sub test_redirect :Global {
+ my ($self, $c) = @_;
+ # Don't set content_type
+ # Don't set body
+ $c->res->redirect('/go_here');
+ # route for /go_here doesn't exist
+ # it is only for checking HTTP response code, content-type etc.
+}
+
+sub test_redirect_uri_for :Global {
+ my ($self, $c) = @_;
+ # Don't set content_type
+ # Don't set body
+ $c->res->redirect($c->uri_for('/go_here'));
+ # route for /go_here doesn't exist
+ # it is only for checking HTTP response code, content-type etc.
+}
+
+sub test_redirect_with_contenttype :Global {
+ my ($self, $c) = @_;
+ # set content_type but don't set body
+ $c->res->content_type('image/jpeg');
+ $c->res->redirect('/go_here');
+ # route for /go_here doesn't exist
+ # it is only for checking HTTP response code, content-type etc.
+}
+
+sub test_redirect_with_content :Global {
+ my ($self, $c) = @_;
+ $c->res->content_type('text/plain');
+ $c->res->body('Please kind sir, I beg you to go to /go_here.');
+ $c->res->redirect('/go_here');
+ # route for /go_here doesn't exist
+ # it is only for checking HTTP response code, content-type etc.
+}
+
+sub test_remove_body_with_304 :Global {
+ my ($self, $c) = @_;
+ $c->res->status(304);
+ $c->res->content_type('text/html');
+ $c->res->body("Body should not be set");
+}
+
+sub test_remove_body_with_204 :Global {
+ my ($self, $c) = @_;
+ $c->res->status(204);
+ $c->res->content_type('text/html');
+ $c->res->body("Body should not be set");
+}
+
+sub test_remove_body_with_100 :Global {
+ my ($self, $c) = @_;
+ $c->res->status(100);
+ $c->res->body("Body should not be set");
+}
+
+sub test_nobody_with_100 :Global {
+ my ($self, $c) = @_;
+ $c->res->status(100);
+}
+
+sub end : Private {
+ my ($self,$c) = @_;
+}
+
1;