X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FTestApp%2FController%2FAction%2FVisit.pm;fp=t%2Flib%2FTestApp%2FController%2FAction%2FVisit.pm;h=3011a750cf951699e1f44ee76c5637aa7be93bd4;hb=ae0e35ee6dd51e78c0ffc2457699beadc7eefab8;hp=0000000000000000000000000000000000000000;hpb=88eee38e25dd1a991008fb5f61b848fcecb97ad0;p=catagits%2FCatalyst-Runtime.git diff --git a/t/lib/TestApp/Controller/Action/Visit.pm b/t/lib/TestApp/Controller/Action/Visit.pm new file mode 100644 index 0000000..3011a75 --- /dev/null +++ b/t/lib/TestApp/Controller/Action/Visit.pm @@ -0,0 +1,101 @@ +package TestApp::Controller::Action::Visit; + +use strict; +use base 'TestApp::Controller::Action'; + +sub one : Local { + my ( $self, $c ) = @_; + $c->visit('two'); +} + +sub two : Private { + my ( $self, $c ) = @_; + $c->visit('three'); +} + +sub three : Local { + my ( $self, $c ) = @_; + $c->visit( $self, 'four' ); +} + +sub four : Private { + my ( $self, $c ) = @_; + $c->visit('/action/visit/five'); +} + +sub five : Local { + my ( $self, $c ) = @_; + $c->forward('View::Dump::Request'); +} + +sub inheritance : Local { + my ( $self, $c ) = @_; + $c->visit('/action/inheritance/a/b/default'); +} + +sub global : Local { + my ( $self, $c ) = @_; + $c->visit('/global_action'); +} + +sub with_args : Local { + my ( $self, $c, $arg ) = @_; + $c->visit( 'args', [$arg] ); +} + +sub with_method_and_args : Local { + my ( $self, $c, $arg ) = @_; + $c->visit( qw/TestApp::Controller::Action::Visit args/, [$arg] ); +} + +sub args : Local { + my ( $self, $c, $val ) = @_; + die "passed argument does not match args" unless $val eq $c->req->args->[0]; + $c->res->body($val); +} + +sub visit_die : Local { + my ( $self, $c, $val ) = @_; + eval { $c->visit( 'args', [qq/new/] ) }; + $c->res->body( $@ ? $@ : "visit() doesn't die" ); +} + +sub visit_chained : Local { + my ( $self, $c, $val ) = @_; + $c->visit('/action/chained/foo/spoon',[1]); +} + +sub view : Local { + my ( $self, $c, $val ) = @_; + eval { $c->visit('View::Dump') }; + $c->res->body( $@ ? $@ : "visit() did not die" ); +} + +sub model : Local { + my ( $self, $c, $val ) = @_; + eval { $c->visit('Model::Foo') }; + $c->res->body( $@ ? $@ : "visit() did not die" ); +} + +sub args_embed_relative : Local { + my ( $self, $c ) = @_; + $c->visit('embed/ok'); +} + +sub args_embed_absolute : Local { + my ( $self, $c ) = @_; + $c->visit('/action/visit/embed/ok'); +} + +sub embed : Local { + my ( $self, $c, $ok ) = @_; + $ok ||= 'not ok'; + $c->res->body($ok); +} + +sub class_visit_test_action : Local { + my ( $self, $c ) = @_; + $c->visit(qw/TestApp class_visit_test_method/); +} + +1;