and the test script
[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
12# :Chained('') defaulting to controller namespace
13# :Chained('..') defaulting to action in controller above
14# :Chained == Chained('/')
15#
16
17#
18# Simple parent/child action test
19#
20sub foo :PathPart('chained/foo') :Captures(1) :Chained('/') { }
21sub endpoint :PathPart('end') :Chained('/action/chained/foo') :Args(1) { }
22
23#
24# Parent/child test with two args each
25#
26sub foo2 :PathPart('chained/foo2') :Captures(2) :Chained('/') { }
27sub endpoint2 :PathPart('end2') :Chained('/action/chained/foo2') :Args(2) { }
28
29#
30# Relative specification of parent action
31#
32sub bar :PathPart('chained/bar') :Chained('/') :Captures(0) { }
33sub finale :PathPart('') :Chained('bar') :Args { }
34
35#
36# three chain with concurrent endpoints
37#
38sub one :PathPart('chained/one') :Chained('/') :Captures(1) { }
39sub two :PathPart('two') :Chained('/action/chained/one') :Captures(2) { }
40sub three_end :PathPart('three') :Chained('two') :Args(3) { }
41sub one_end :PathPart('chained/one') :Chained('/') :Args(1) { }
42sub two_end :PathPart('two') :Chained('one') :Args(2) { }
43
44#
45# Dispatch on number of arguments
46#
47sub multi1 :PathPart('chained/multi') :Chained('/') :Args(1) { }
48sub multi2 :PathPart('chained/multi') :Chained('/') :Args(2) { }
49
50#
51# Roots in an action defined in a higher controller
52#
53sub higher_root :PathPart('bar') :Chained('/action/chained/foo/higher_root') :Args(1) { }
54
55#
56# Controller -> subcontroller -> controller
57#
58sub pcp1 :PathPart('chained/pcp1') :Chained('/') :Captures(1) { }
59sub pcp3 :Chained('/action/chained/foo/pcp2') :Args(1) { }
60
61#
62# Dispatch on capture number
63#
64sub multi_cap1 :PathPart('chained/multi_cap') :Chained('/') :Captures(1) { }
65sub multi_cap2 :PathPart('chained/multi_cap') :Chained('/') :Captures(2) { }
66sub multi_cap_end1 :PathPart('baz') :Chained('multi_cap1') :Args(0) { }
67sub multi_cap_end2 :PathPart('baz') :Chained('multi_cap2') :Args(0) { }
68
69#
70# Priority: Slurpy args vs. chained actions
71#
72sub priority_a1 :PathPart('chained/priority_a') :Chained('/') :Args { }
73sub priority_a2 :PathPart('chained/priority_a') :Chained('/') :Captures(1) { }
74sub priority_a2_end :PathPart('end') :Chained('priority_a2') :Args(1) { }
75
76#
77# Priority: Fixed args vs. chained actions
78#
79sub priority_b1 :PathPart('chained/priority_b') :Chained('/') :Args(3) { }
80sub priority_b2 :PathPart('chained/priority_b') :Chained('/') :Captures(1) { }
81sub priority_b2_end :PathPart('end') :Chained('priority_b2') :Args(1) { }
82
83#
84# Optional specification of :Args in endpoint
85#
86sub opt_args :PathPart('chained/opt_args') :Chained('/') { }
87
88#
89# Optional PathPart test -> /chained/optpp/*/opt_pathpart/*
90#
91sub opt_pp_start :Chained('/') :PathPart('chained/optpp') :Captures(1) { }
92sub opt_pathpart :Chained('opt_pp_start') :Args(1) { }
93
94#
95# Optional Args *and* PathPart -> /chained/optall/*/oa/...
96#
97sub opt_all_start :Chained('/') :PathPart('chained/optall') :Captures(1) { }
98sub oa :Chained('opt_all_start') { }
99
100sub end :Private {
101 my ($self, $c) = @_;
102 my $out = join('; ', map { join(', ', @$_) }
103 ($c->req->captures, $c->req->args));
104 $c->res->body($out);
105}
106
1071;