Much cleaner. The visit class test wasn't actually testing visiting the class, so...
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / Action / Visit.pm
CommitLineData
ae0e35ee 1package TestApp::Controller::Action::Visit;
2
3use strict;
4use base 'TestApp::Controller::Action';
5
6sub one : Local {
7 my ( $self, $c ) = @_;
8 $c->visit('two');
9}
10
11sub two : Private {
12 my ( $self, $c ) = @_;
13 $c->visit('three');
14}
15
16sub three : Local {
17 my ( $self, $c ) = @_;
18 $c->visit( $self, 'four' );
19}
20
21sub four : Private {
22 my ( $self, $c ) = @_;
23 $c->visit('/action/visit/five');
24}
25
26sub five : Local {
27 my ( $self, $c ) = @_;
28 $c->forward('View::Dump::Request');
29}
30
31sub inheritance : Local {
32 my ( $self, $c ) = @_;
33 $c->visit('/action/inheritance/a/b/default');
34}
35
36sub global : Local {
37 my ( $self, $c ) = @_;
38 $c->visit('/global_action');
39}
40
41sub with_args : Local {
42 my ( $self, $c, $arg ) = @_;
43 $c->visit( 'args', [$arg] );
44}
45
46sub with_method_and_args : Local {
47 my ( $self, $c, $arg ) = @_;
48 $c->visit( qw/TestApp::Controller::Action::Visit args/, [$arg] );
49}
50
51sub args : Local {
52 my ( $self, $c, $val ) = @_;
53 die "passed argument does not match args" unless $val eq $c->req->args->[0];
54 $c->res->body($val);
55}
56
57sub visit_die : Local {
58 my ( $self, $c, $val ) = @_;
59 eval { $c->visit( 'args', [qq/new/] ) };
60 $c->res->body( $@ ? $@ : "visit() doesn't die" );
61}
62
63sub visit_chained : Local {
b456f8f3 64 my ( $self, $c, $val, $capture, @args ) = @_;
65 my @cap_and_args = ([$capture], [@args]);
66 $val eq 1 ? $c->visit( '/action/chained/foo/spoon', @cap_and_args)
67 : $val eq 2 ? $c->visit( qw/ Action::Chained::Foo spoon /, @cap_and_args)
68 : $c->visit( $c->controller('Action::Chained::Foo')->action_for('spoon'), @cap_and_args)
ae0e35ee 69}
70
71sub view : Local {
72 my ( $self, $c, $val ) = @_;
73 eval { $c->visit('View::Dump') };
74 $c->res->body( $@ ? $@ : "visit() did not die" );
75}
76
77sub model : Local {
78 my ( $self, $c, $val ) = @_;
79 eval { $c->visit('Model::Foo') };
80 $c->res->body( $@ ? $@ : "visit() did not die" );
81}
82
83sub args_embed_relative : Local {
84 my ( $self, $c ) = @_;
85 $c->visit('embed/ok');
86}
87
88sub args_embed_absolute : Local {
89 my ( $self, $c ) = @_;
90 $c->visit('/action/visit/embed/ok');
91}
92
93sub embed : Local {
94 my ( $self, $c, $ok ) = @_;
95 $ok ||= 'not ok';
96 $c->res->body($ok);
97}
98
99sub class_visit_test_action : Local {
100 my ( $self, $c ) = @_;
382d317c 101 $c->visit(qw/TestApp/);
ae0e35ee 102}
103
1041;