X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FTestApp%2FController%2FRoot.pm;h=c1bd6d522ef93a6557a3af352c0663560afd42ae;hb=11e7af55dda3f3acd9ab3b484b54180f76b253df;hp=53d79e2bacbe55924651301f5e3f1e7df5b1cae8;hpb=2f3812528068bc1d9f7840067f0c03d36cd47e6d;p=catagits%2FCatalyst-Runtime.git diff --git a/t/lib/TestApp/Controller/Root.pm b/t/lib/TestApp/Controller/Root.pm index 53d79e2..c1bd6d5 100644 --- a/t/lib/TestApp/Controller/Root.pm +++ b/t/lib/TestApp/Controller/Root.pm @@ -1,5 +1,6 @@ package TestApp::Controller::Root; - +use strict; +use warnings; use base 'Catalyst::Controller'; __PACKAGE__->config->{namespace} = ''; @@ -13,6 +14,16 @@ sub zero : Path('0') { $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 localregex : LocalRegex('^localregex$') { my ( $self, $c ) = @_; $c->res->header( 'X-Test-Class' => ref($self) ); @@ -20,4 +31,82 @@ sub localregex : LocalRegex('^localregex$') { $c->forward('TestApp::View::Dump::Request'); } +sub index : Private { + my ( $self, $c ) = @_; + $c->res->body('root index'); +} + +sub global_action : Private { + my ( $self, $c ) = @_; + $c->forward('TestApp::View::Dump::Request'); +} + +sub class_forward_test_method :Private { + my ( $self, $c ) = @_; + $c->response->headers->header( 'X-Class-Forward-Test-Method' => 1 ); +} + +sub loop_test : Local { + my ( $self, $c ) = @_; + + for( 1..1001 ) { + $c->forward( 'class_forward_test_method' ); + } +} + +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'); +} + +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'); +} + +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'); +} + +sub end : Private { + my ($self,$c) = @_; +} + 1;