Captures -> CapureArgs
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / Action / Chained.pm
CommitLineData
5882c86e 1package TestApp::Controller::Action::Chained;
2
3use strict;
4use warnings;
5
6use base qw/Catalyst::Controller/;
7
8sub begin :Private { }
9
10#
11# TODO
0e853a7f 12# :Chained('') means what?
5882c86e 13#
14
15#
16# Simple parent/child action test
17#
1c34f703 18sub foo :PathPart('chained/foo') :CaptureArgs(1) :Chained('/') { }
5882c86e 19sub endpoint :PathPart('end') :Chained('/action/chained/foo') :Args(1) { }
20
21#
22# Parent/child test with two args each
23#
1c34f703 24sub foo2 :PathPart('chained/foo2') :CaptureArgs(2) :Chained('/') { }
5882c86e 25sub endpoint2 :PathPart('end2') :Chained('/action/chained/foo2') :Args(2) { }
26
27#
28# Relative specification of parent action
29#
1c34f703 30sub bar :PathPart('chained/bar') :Chained('/') :CaptureArgs(0) { }
5882c86e 31sub finale :PathPart('') :Chained('bar') :Args { }
32
33#
34# three chain with concurrent endpoints
35#
1c34f703 36sub one :PathPart('chained/one') :Chained('/') :CaptureArgs(1) { }
37sub two :PathPart('two') :Chained('/action/chained/one') :CaptureArgs(2) { }
5882c86e 38sub three_end :PathPart('three') :Chained('two') :Args(3) { }
39sub one_end :PathPart('chained/one') :Chained('/') :Args(1) { }
40sub two_end :PathPart('two') :Chained('one') :Args(2) { }
41
42#
43# Dispatch on number of arguments
44#
45sub multi1 :PathPart('chained/multi') :Chained('/') :Args(1) { }
46sub multi2 :PathPart('chained/multi') :Chained('/') :Args(2) { }
47
48#
49# Roots in an action defined in a higher controller
50#
51sub higher_root :PathPart('bar') :Chained('/action/chained/foo/higher_root') :Args(1) { }
52
53#
54# Controller -> subcontroller -> controller
55#
1c34f703 56sub pcp1 :PathPart('chained/pcp1') :Chained('/') :CaptureArgs(1) { }
5882c86e 57sub pcp3 :Chained('/action/chained/foo/pcp2') :Args(1) { }
58
59#
60# Dispatch on capture number
61#
1c34f703 62sub multi_cap1 :PathPart('chained/multi_cap') :Chained('/') :CaptureArgs(1) { }
63sub multi_cap2 :PathPart('chained/multi_cap') :Chained('/') :CaptureArgs(2) { }
5882c86e 64sub multi_cap_end1 :PathPart('baz') :Chained('multi_cap1') :Args(0) { }
65sub multi_cap_end2 :PathPart('baz') :Chained('multi_cap2') :Args(0) { }
66
67#
68# Priority: Slurpy args vs. chained actions
69#
70sub priority_a1 :PathPart('chained/priority_a') :Chained('/') :Args { }
1c34f703 71sub priority_a2 :PathPart('chained/priority_a') :Chained('/') :CaptureArgs(1) { }
5882c86e 72sub priority_a2_end :PathPart('end') :Chained('priority_a2') :Args(1) { }
73
74#
75# Priority: Fixed args vs. chained actions
76#
77sub priority_b1 :PathPart('chained/priority_b') :Chained('/') :Args(3) { }
1c34f703 78sub priority_b2 :PathPart('chained/priority_b') :Chained('/') :CaptureArgs(1) { }
5882c86e 79sub priority_b2_end :PathPart('end') :Chained('priority_b2') :Args(1) { }
80
81#
82# Optional specification of :Args in endpoint
83#
84sub opt_args :PathPart('chained/opt_args') :Chained('/') { }
85
86#
87# Optional PathPart test -> /chained/optpp/*/opt_pathpart/*
88#
1c34f703 89sub opt_pp_start :Chained('/') :PathPart('chained/optpp') :CaptureArgs(1) { }
5882c86e 90sub opt_pathpart :Chained('opt_pp_start') :Args(1) { }
91
92#
93# Optional Args *and* PathPart -> /chained/optall/*/oa/...
94#
1c34f703 95sub opt_all_start :Chained('/') :PathPart('chained/optall') :CaptureArgs(1) { }
5882c86e 96sub oa :Chained('opt_all_start') { }
97
0e853a7f 98#
99# :Chained is the same as :Chained('/')
100#
101sub rootdef :Chained :PathPart('chained/rootdef') :Args(1) { }
102
103#
104# the ParentChain controller chains to this action by
105# specifying :Chained('.')
106#
1c34f703 107sub parentchain :Chained('/') :PathPart('chained/parentchain') :CaptureArgs(1) { }
0e853a7f 108
2349aeea 109#
110# This is just for a test that a loose end is not callable
111#
1c34f703 112sub loose :Chained :PathPart('chained/loose') CaptureArgs(1) { }
2349aeea 113
114#
115# Forwarding out of the middle of a chain.
116#
1c34f703 117sub chain_fw_a :Chained :PathPart('chained/chain_fw') :CaptureArgs(1) {
2349aeea 118 $_[1]->forward( '/action/chained/fw_dt_target' );
119}
120sub chain_fw_b :Chained('chain_fw_a') :PathPart('end') :Args(1) { }
121
122#
123# Detaching out of the middle of a chain.
124#
1c34f703 125sub chain_dt_a :Chained :PathPart('chained/chain_dt') :CaptureArgs(1) {
2349aeea 126 $_[1]->detach( '/action/chained/fw_dt_target' );
127}
128sub chain_dt_b :Chained('chain_dt_a') :PathPart('end') :Args(1) { }
129
130#
131# Target for former forward and chain tests.
132#
133sub fw_dt_target :Private { }
134
5882c86e 135sub end :Private {
136 my ($self, $c) = @_;
137 my $out = join('; ', map { join(', ', @$_) }
138 ($c->req->captures, $c->req->args));
139 $c->res->body($out);
140}
141
1421;