From: Matt S Trout Date: Thu, 22 Jun 2006 14:52:09 +0000 (+0000) Subject: rah. rename everything. X-Git-Tag: 5.7099_04~488 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=5882c86e1f256e122583dcc311b17bdbf9a4d766 rah. rename everything. r10068@cain (orig r4399): matthewt | 2006-06-17 21:21:25 +0000 --- diff --git a/lib/Catalyst/DispatchType/ChildOf.pm b/lib/Catalyst/DispatchType/Chained.pm similarity index 93% rename from lib/Catalyst/DispatchType/ChildOf.pm rename to lib/Catalyst/DispatchType/Chained.pm index 2ab537e..132d9ef 100644 --- a/lib/Catalyst/DispatchType/ChildOf.pm +++ b/lib/Catalyst/DispatchType/Chained.pm @@ -1,4 +1,4 @@ -package Catalyst::DispatchType::ChildOf; +package Catalyst::DispatchType::Chained; use strict; use base qw/Catalyst::DispatchType/; @@ -10,7 +10,7 @@ use URI; =head1 NAME -Catalyst::DispatchType::ChildOf - Path Part DispatchType +Catalyst::DispatchType::Chained - Path Part DispatchType =head1 SYNOPSIS @@ -52,7 +52,7 @@ sub list { unshift(@parts, $pp->[0]) if (defined $pp->[0] && length $pp->[0]); } - $parent = $curr->attributes->{ChildOf}->[0]; + $parent = $curr->attributes->{Chained}->[0]; $curr = $self->{actions}{$parent}; unshift(@parents, $curr) if $curr; } @@ -163,13 +163,13 @@ Matt is an idiot and hasn't documented this yet. sub register { my ( $self, $c, $action ) = @_; - my @child_of_attr = @{ $action->attributes->{ChildOf} || [] }; + my @child_of_attr = @{ $action->attributes->{Chained} || [] }; return 0 unless @child_of_attr; if (@child_of_attr > 2) { Catalyst::Exception->throw( - "Multiple ChildOf attributes not supported registering ${action}" + "Multiple Chained attributes not supported registering ${action}" ); } @@ -183,7 +183,7 @@ sub register { $parent = '/'.$action->namespace; } - $action->attributes->{ChildOf} = [ $parent ]; + $action->attributes->{Chained} = [ $parent ]; my $children = ($self->{children_of}{$parent} ||= {}); @@ -221,7 +221,7 @@ Matt is an idiot and hasn't documented this yet. sub uri_for_action { my ( $self, $action, $captures ) = @_; - return undef unless ($action->attributes->{ChildOf} + return undef unless ($action->attributes->{Chained} && $action->attributes->{Args}); my @parts = (); @@ -237,7 +237,7 @@ sub uri_for_action { unshift(@parts, $pp->[0]) if (defined $pp->[0] && length $pp->[0]); } - $parent = $curr->attributes->{ChildOf}->[0]; + $parent = $curr->attributes->{Chained}->[0]; $curr = $self->{actions}{$parent}; } diff --git a/lib/Catalyst/Manual/Intro.pod b/lib/Catalyst/Manual/Intro.pod index 3e6eff3..21a701d 100644 --- a/lib/Catalyst/Manual/Intro.pod +++ b/lib/Catalyst/Manual/Intro.pod @@ -417,21 +417,21 @@ C<$c-Ereq-Ecaptures-E[0]> would be "23". If you want to pass arguments at the end of your URL, you must use regex action keys. See L below. -=item * B +=item * B - sub section :PathPart('section') :ChildOf('/') :Captures(1) { } + sub section :PathPart('section') :Chained('/') :Captures(1) { } -ChildOf is a powerful way to handle canonical URIs of the form +Chained is a powerful way to handle canonical URIs of the form C. Using this URI as an example, in Controller::Root you can do the following: - sub section_handler :PathPart('section') :ChildOf('/') :Captures(1) { + sub section_handler :PathPart('section') :Chained('/') :Captures(1) { my ( $self, $c ) = @_; $c->stash->{'section'} = $c->Model('Sections')->find($c->req->captures->[0]); } - sub item_handler :PathPart('item') :ChildOf('/section_handler') :Args(1) { + sub item_handler :PathPart('item') :Chained('/section_handler') :Args(1) { my ( $self, $c ) = @_; $c->stash->{'item'} = $c->stash->{'section'}->find_related('item',$c->args->[0]); @@ -448,37 +448,37 @@ L below for more options. A parent action can be in any controller or namespace. -Multiple actions can specify the same parent action in their C; +Multiple actions can specify the same parent action in their C; that is, one action can have multiple children. -=item ChildOf('xyz') +=item Chained('xyz') The action of the parent. For instance, if you have a method C in the controller C, the action would be C. For a Root handler this would be '/'. For an action in the same controller namespace you can use -a relative name like C<:ChildOf('foo')>. +a relative name like C<:Chained('foo')>. =item PathPart('xyz') -The name of this path section in the ChildOf tree mapping to the URI. If +The name of this path section in the Chained tree mapping to the URI. If you specify C<:PathPart> without arguments, it takes the name of the action specifying the argument. For example, these two declarations have the same effect: - sub foo :PathPart('foo') :ChildOf('bar') :Args(1) { + sub foo :PathPart('foo') :Chained('bar') :Args(1) { ... } and - sub foo :PathPart :ChildOf('bar') :Args(1) { + sub foo :PathPart :Chained('bar') :Args(1) { ... } The value can also contain a slash, for example: - sub baz :PathPart('bar/baz') :ChildOf('/') :Captures(1) { + sub baz :PathPart('bar/baz') :Chained('/') :Captures(1) { ... } @@ -488,7 +488,7 @@ would be involved in matches on C paths. Will 'collapse' the next C path segments in the request URI and push them into the arrayref C<$c-Ereq-Ecaptures>. An action -specifying C is thought to be used as target for C +specifying C is thought to be used as target for C specifications. Also see the C attribute below, which is used for endpoints. @@ -500,7 +500,7 @@ equivalent of the index action. Args with no parameters will capture every postfixed segment into C<$c-Ereq-Eargs>. A specification of C is seen as endpoint in regard to an additional -C specification. +C specification. =item * B (B) diff --git a/t/lib/TestApp/Controller/Action/Chained.pm b/t/lib/TestApp/Controller/Action/Chained.pm new file mode 100644 index 0000000..6bb0acf --- /dev/null +++ b/t/lib/TestApp/Controller/Action/Chained.pm @@ -0,0 +1,107 @@ +package TestApp::Controller::Action::Chained; + +use strict; +use warnings; + +use base qw/Catalyst::Controller/; + +sub begin :Private { } + +# +# TODO +# :Chained('') defaulting to controller namespace +# :Chained('..') defaulting to action in controller above +# :Chained == Chained('/') +# + +# +# Simple parent/child action test +# +sub foo :PathPart('chained/foo') :Captures(1) :Chained('/') { } +sub endpoint :PathPart('end') :Chained('/action/chained/foo') :Args(1) { } + +# +# Parent/child test with two args each +# +sub foo2 :PathPart('chained/foo2') :Captures(2) :Chained('/') { } +sub endpoint2 :PathPart('end2') :Chained('/action/chained/foo2') :Args(2) { } + +# +# Relative specification of parent action +# +sub bar :PathPart('chained/bar') :Chained('/') :Captures(0) { } +sub finale :PathPart('') :Chained('bar') :Args { } + +# +# three chain with concurrent endpoints +# +sub one :PathPart('chained/one') :Chained('/') :Captures(1) { } +sub two :PathPart('two') :Chained('/action/chained/one') :Captures(2) { } +sub three_end :PathPart('three') :Chained('two') :Args(3) { } +sub one_end :PathPart('chained/one') :Chained('/') :Args(1) { } +sub two_end :PathPart('two') :Chained('one') :Args(2) { } + +# +# Dispatch on number of arguments +# +sub multi1 :PathPart('chained/multi') :Chained('/') :Args(1) { } +sub multi2 :PathPart('chained/multi') :Chained('/') :Args(2) { } + +# +# Roots in an action defined in a higher controller +# +sub higher_root :PathPart('bar') :Chained('/action/chained/foo/higher_root') :Args(1) { } + +# +# Controller -> subcontroller -> controller +# +sub pcp1 :PathPart('chained/pcp1') :Chained('/') :Captures(1) { } +sub pcp3 :Chained('/action/chained/foo/pcp2') :Args(1) { } + +# +# Dispatch on capture number +# +sub multi_cap1 :PathPart('chained/multi_cap') :Chained('/') :Captures(1) { } +sub multi_cap2 :PathPart('chained/multi_cap') :Chained('/') :Captures(2) { } +sub multi_cap_end1 :PathPart('baz') :Chained('multi_cap1') :Args(0) { } +sub multi_cap_end2 :PathPart('baz') :Chained('multi_cap2') :Args(0) { } + +# +# Priority: Slurpy args vs. chained actions +# +sub priority_a1 :PathPart('chained/priority_a') :Chained('/') :Args { } +sub priority_a2 :PathPart('chained/priority_a') :Chained('/') :Captures(1) { } +sub priority_a2_end :PathPart('end') :Chained('priority_a2') :Args(1) { } + +# +# Priority: Fixed args vs. chained actions +# +sub priority_b1 :PathPart('chained/priority_b') :Chained('/') :Args(3) { } +sub priority_b2 :PathPart('chained/priority_b') :Chained('/') :Captures(1) { } +sub priority_b2_end :PathPart('end') :Chained('priority_b2') :Args(1) { } + +# +# Optional specification of :Args in endpoint +# +sub opt_args :PathPart('chained/opt_args') :Chained('/') { } + +# +# Optional PathPart test -> /chained/optpp/*/opt_pathpart/* +# +sub opt_pp_start :Chained('/') :PathPart('chained/optpp') :Captures(1) { } +sub opt_pathpart :Chained('opt_pp_start') :Args(1) { } + +# +# Optional Args *and* PathPart -> /chained/optall/*/oa/... +# +sub opt_all_start :Chained('/') :PathPart('chained/optall') :Captures(1) { } +sub oa :Chained('opt_all_start') { } + +sub end :Private { + my ($self, $c) = @_; + my $out = join('; ', map { join(', ', @$_) } + ($c->req->captures, $c->req->args)); + $c->res->body($out); +} + +1; diff --git a/t/lib/TestApp/Controller/Action/ChildOf/Bar.pm b/t/lib/TestApp/Controller/Action/Chained/Bar.pm similarity index 60% rename from t/lib/TestApp/Controller/Action/ChildOf/Bar.pm rename to t/lib/TestApp/Controller/Action/Chained/Bar.pm index f83a882..88f6de6 100644 --- a/t/lib/TestApp/Controller/Action/ChildOf/Bar.pm +++ b/t/lib/TestApp/Controller/Action/Chained/Bar.pm @@ -1,4 +1,4 @@ -package TestApp::Controller::Action::ChildOf::Bar; +package TestApp::Controller::Action::Chained::Bar; use strict; use warnings; @@ -9,6 +9,6 @@ use base qw/Catalyst::Controller/; # Redispatching between controllers that are not in a parent/child # relation. This is the root. # -sub cross1 :PathPart('childof/cross') :Captures(1) :ChildOf('/') { } +sub cross1 :PathPart('chained/cross') :Captures(1) :Chained('/') { } 1; diff --git a/t/lib/TestApp/Controller/Action/ChildOf/Foo.pm b/t/lib/TestApp/Controller/Action/Chained/Foo.pm similarity index 54% rename from t/lib/TestApp/Controller/Action/ChildOf/Foo.pm rename to t/lib/TestApp/Controller/Action/Chained/Foo.pm index d75f45a..2ebd39d 100644 --- a/t/lib/TestApp/Controller/Action/ChildOf/Foo.pm +++ b/t/lib/TestApp/Controller/Action/Chained/Foo.pm @@ -1,4 +1,4 @@ -package TestApp::Controller::Action::ChildOf::Foo; +package TestApp::Controller::Action::Chained::Foo; use strict; use warnings; @@ -8,21 +8,21 @@ use base qw/Catalyst::Controller/; # # Child of current namespace # -sub spoon :ChildOf('') :Args(0) { } +sub spoon :Chained('') :Args(0) { } # # Root for a action in a "parent" controller # -sub higher_root :PathPart('childof/higher_root') :ChildOf('/') :Captures(1) { } +sub higher_root :PathPart('chained/higher_root') :Chained('/') :Captures(1) { } # # Parent controller -> this subcontroller -> parent controller test # -sub pcp2 :ChildOf('/action/childof/pcp1') :Captures(1) { } +sub pcp2 :Chained('/action/chained/pcp1') :Captures(1) { } # # Controllers not in parent/child relation. This tests the end. # -sub cross2 :PathPart('end') :ChildOf('/action/childof/bar/cross1') :Args(1) { } +sub cross2 :PathPart('end') :Chained('/action/chained/bar/cross1') :Args(1) { } 1; diff --git a/t/lib/TestApp/Controller/Action/ChildOf/PassedArgs.pm b/t/lib/TestApp/Controller/Action/Chained/PassedArgs.pm similarity index 73% rename from t/lib/TestApp/Controller/Action/ChildOf/PassedArgs.pm rename to t/lib/TestApp/Controller/Action/Chained/PassedArgs.pm index 831f778..a84346f 100644 --- a/t/lib/TestApp/Controller/Action/ChildOf/PassedArgs.pm +++ b/t/lib/TestApp/Controller/Action/Chained/PassedArgs.pm @@ -1,4 +1,4 @@ -package TestApp::Controller::Action::ChildOf::PassedArgs; +package TestApp::Controller::Action::Chained::PassedArgs; use warnings; use strict; @@ -11,17 +11,17 @@ use base qw( Catalyst::Controller ); # as it should. # -sub first : PathPart('childof/passedargs/a') ChildOf('/') Captures(1) { +sub first : PathPart('chained/passedargs/a') Chained('/') Captures(1) { my ( $self, $c, $arg ) = @_; $c->stash->{ passed_args } = [ $arg ]; } -sub second : PathPart('b') ChildOf('first') Captures(1) { +sub second : PathPart('b') Chained('first') Captures(1) { my ( $self, $c, $arg ) = @_; push @{ $c->stash->{ passed_args } }, $arg; } -sub third : PathPart('c') ChildOf('second') Args(1) { +sub third : PathPart('c') Chained('second') Args(1) { my ( $self, $c, $arg ) = @_; push @{ $c->stash->{ passed_args } }, $arg; } diff --git a/t/lib/TestApp/Controller/Action/ChildOf.pm b/t/lib/TestApp/Controller/Action/ChildOf.pm deleted file mode 100644 index 24fe369..0000000 --- a/t/lib/TestApp/Controller/Action/ChildOf.pm +++ /dev/null @@ -1,107 +0,0 @@ -package TestApp::Controller::Action::ChildOf; - -use strict; -use warnings; - -use base qw/Catalyst::Controller/; - -sub begin :Private { } - -# -# TODO -# :ChildOf('') defaulting to controller namespace -# :ChildOf('..') defaulting to action in controller above -# :ChildOf == ChildOf('/') -# - -# -# Simple parent/child action test -# -sub foo :PathPart('childof/foo') :Captures(1) :ChildOf('/') { } -sub endpoint :PathPart('end') :ChildOf('/action/childof/foo') :Args(1) { } - -# -# Parent/child test with two args each -# -sub foo2 :PathPart('childof/foo2') :Captures(2) :ChildOf('/') { } -sub endpoint2 :PathPart('end2') :ChildOf('/action/childof/foo2') :Args(2) { } - -# -# Relative specification of parent action -# -sub bar :PathPart('childof/bar') :ChildOf('/') :Captures(0) { } -sub finale :PathPart('') :ChildOf('bar') :Args { } - -# -# three chain with concurrent endpoints -# -sub one :PathPart('childof/one') :ChildOf('/') :Captures(1) { } -sub two :PathPart('two') :ChildOf('/action/childof/one') :Captures(2) { } -sub three_end :PathPart('three') :ChildOf('two') :Args(3) { } -sub one_end :PathPart('childof/one') :ChildOf('/') :Args(1) { } -sub two_end :PathPart('two') :ChildOf('one') :Args(2) { } - -# -# Dispatch on number of arguments -# -sub multi1 :PathPart('childof/multi') :ChildOf('/') :Args(1) { } -sub multi2 :PathPart('childof/multi') :ChildOf('/') :Args(2) { } - -# -# Roots in an action defined in a higher controller -# -sub higher_root :PathPart('bar') :ChildOf('/action/childof/foo/higher_root') :Args(1) { } - -# -# Controller -> subcontroller -> controller -# -sub pcp1 :PathPart('childof/pcp1') :ChildOf('/') :Captures(1) { } -sub pcp3 :ChildOf('/action/childof/foo/pcp2') :Args(1) { } - -# -# Dispatch on capture number -# -sub multi_cap1 :PathPart('childof/multi_cap') :ChildOf('/') :Captures(1) { } -sub multi_cap2 :PathPart('childof/multi_cap') :ChildOf('/') :Captures(2) { } -sub multi_cap_end1 :PathPart('baz') :ChildOf('multi_cap1') :Args(0) { } -sub multi_cap_end2 :PathPart('baz') :ChildOf('multi_cap2') :Args(0) { } - -# -# Priority: Slurpy args vs. chained actions -# -sub priority_a1 :PathPart('childof/priority_a') :ChildOf('/') :Args { } -sub priority_a2 :PathPart('childof/priority_a') :ChildOf('/') :Captures(1) { } -sub priority_a2_end :PathPart('end') :ChildOf('priority_a2') :Args(1) { } - -# -# Priority: Fixed args vs. chained actions -# -sub priority_b1 :PathPart('childof/priority_b') :ChildOf('/') :Args(3) { } -sub priority_b2 :PathPart('childof/priority_b') :ChildOf('/') :Captures(1) { } -sub priority_b2_end :PathPart('end') :ChildOf('priority_b2') :Args(1) { } - -# -# Optional specification of :Args in endpoint -# -sub opt_args :PathPart('childof/opt_args') :ChildOf('/') { } - -# -# Optional PathPart test -> /childof/optpp/*/opt_pathpart/* -# -sub opt_pp_start :ChildOf('/') :PathPart('childof/optpp') :Captures(1) { } -sub opt_pathpart :ChildOf('opt_pp_start') :Args(1) { } - -# -# Optional Args *and* PathPart -> /childof/optall/*/oa/... -# -sub opt_all_start :ChildOf('/') :PathPart('childof/optall') :Captures(1) { } -sub oa :ChildOf('opt_all_start') { } - -sub end :Private { - my ($self, $c) = @_; - my $out = join('; ', map { join(', ', @$_) } - ($c->req->captures, $c->req->args)); - $c->res->body($out); -} - -1; diff --git a/t/live_component_controller_action_childof.t b/t/live_component_controller_action_childof.t index 712d033..46d95a9 100644 --- a/t/live_component_controller_action_childof.t +++ b/t/live_component_controller_action_childof.t @@ -31,15 +31,15 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->foo - TestApp::Controller::Action::ChildOf->endpoint - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->foo + TestApp::Controller::Action::Chained->endpoint + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/foo/1/end/2'), 'childof + local endpoint' ); + ok( my $response = request('http://localhost/chained/foo/1/end/2'), 'chained + local endpoint' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); is( $response->content, '1; 2', 'Content OK' ); @@ -52,8 +52,8 @@ sub run_tests { { my $expected = undef; - ok( my $response = request('http://localhost/childof/foo/1/end'), - 'childof + local endpoint; missing last argument' ); + ok( my $response = request('http://localhost/chained/foo/1/end'), + 'chained + local endpoint; missing last argument' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); is( $response->header('Status'), 500, 'Status OK' ); @@ -64,35 +64,35 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->foo - TestApp::Controller::Action::ChildOf::Foo->spoon - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->foo + TestApp::Controller::Action::Chained::Foo->spoon + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/foo/1/spoon'), 'childof + subcontroller endpoint' ); + ok( my $response = request('http://localhost/chained/foo/1/spoon'), 'chained + subcontroller endpoint' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); is( $response->content, '1; ', 'Content OK' ); } # - # Tests if the relative specification (e.g.: ChildOf('bar') ) works + # Tests if the relative specification (e.g.: Chained('bar') ) works # as expected. # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->bar - TestApp::Controller::Action::ChildOf->finale - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->bar + TestApp::Controller::Action::Chained->finale + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/bar/1/spoon'), 'childof + relative endpoint' ); + ok( my $response = request('http://localhost/chained/bar/1/spoon'), 'chained + relative endpoint' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); is( $response->content, '; 1, spoon', 'Content OK' ); @@ -103,16 +103,16 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->foo2 - TestApp::Controller::Action::ChildOf->endpoint2 - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->foo2 + TestApp::Controller::Action::Chained->endpoint2 + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/foo2/10/20/end2/15/25'), - 'childof + local (2 args each)' ); + ok( my $response = request('http://localhost/chained/foo2/10/20/end2/15/25'), + 'chained + local (2 args each)' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); is( $response->content, '10, 20; 15, 25', 'Content OK' ); @@ -125,14 +125,14 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->one_end - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->one_end + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/one/23'), + ok( my $response = request('http://localhost/chained/one/23'), 'three-chain (only first)' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -146,15 +146,15 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->one - TestApp::Controller::Action::ChildOf->two_end - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->one + TestApp::Controller::Action::Chained->two_end + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/one/23/two/23/46'), + ok( my $response = request('http://localhost/chained/one/23/two/23/46'), 'three-chain (up to second)' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -168,16 +168,16 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->one - TestApp::Controller::Action::ChildOf->two - TestApp::Controller::Action::ChildOf->three_end - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->one + TestApp::Controller::Action::Chained->two + TestApp::Controller::Action::Chained->three_end + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/one/23/two/23/46/three/1/2/3'), + ok( my $response = request('http://localhost/chained/one/23/two/23/46/three/1/2/3'), 'three-chain (all three)' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -190,14 +190,14 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->multi1 - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->multi1 + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/multi/23'), + ok( my $response = request('http://localhost/chained/multi/23'), 'multi-action (one arg)' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -209,14 +209,14 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->multi2 - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->multi2 + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/multi/23/46'), + ok( my $response = request('http://localhost/chained/multi/23/46'), 'multi-action (two args)' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -230,7 +230,7 @@ sub run_tests { { my $expected = undef; - ok( my $response = request('http://localhost/childof/multi/23/46/67'), + ok( my $response = request('http://localhost/chained/multi/23/46/67'), 'multi-action (three args, should lead to error)' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -243,15 +243,15 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf::Foo->higher_root - TestApp::Controller::Action::ChildOf->higher_root - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained::Foo->higher_root + TestApp::Controller::Action::Chained->higher_root + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/higher_root/23/bar/11'), + ok( my $response = request('http://localhost/chained/higher_root/23/bar/11'), 'root higher than child' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -264,16 +264,16 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->pcp1 - TestApp::Controller::Action::ChildOf::Foo->pcp2 - TestApp::Controller::Action::ChildOf->pcp3 - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->pcp1 + TestApp::Controller::Action::Chained::Foo->pcp2 + TestApp::Controller::Action::Chained->pcp3 + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/pcp1/1/pcp2/2/pcp3/3'), + ok( my $response = request('http://localhost/chained/pcp1/1/pcp2/2/pcp3/3'), 'parent -> child -> parent' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -285,15 +285,15 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->multi_cap1 - TestApp::Controller::Action::ChildOf->multi_cap_end1 - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->multi_cap1 + TestApp::Controller::Action::Chained->multi_cap_end1 + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/multi_cap/1/baz'), + ok( my $response = request('http://localhost/chained/multi_cap/1/baz'), 'dispatch on capture num 1' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -306,15 +306,15 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->multi_cap2 - TestApp::Controller::Action::ChildOf->multi_cap_end2 - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->multi_cap2 + TestApp::Controller::Action::Chained->multi_cap_end2 + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/multi_cap/1/2/baz'), + ok( my $response = request('http://localhost/chained/multi_cap/1/2/baz'), 'dispatch on capture num 2' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -327,15 +327,15 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->priority_a2 - TestApp::Controller::Action::ChildOf->priority_a2_end - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->priority_a2 + TestApp::Controller::Action::Chained->priority_a2_end + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/priority_a/1/end/2'), + ok( my $response = request('http://localhost/chained/priority_a/1/end/2'), 'priority - slurpy args vs. parent/child' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -348,15 +348,15 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->priority_b2 - TestApp::Controller::Action::ChildOf->priority_b2_end - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->priority_b2 + TestApp::Controller::Action::Chained->priority_b2_end + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/priority_b/1/end/2'), + ok( my $response = request('http://localhost/chained/priority_b/1/end/2'), 'priority - fixed args vs. parent/child' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -369,15 +369,15 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf::Bar->cross1 - TestApp::Controller::Action::ChildOf::Foo->cross2 - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained::Bar->cross1 + TestApp::Controller::Action::Chained::Foo->cross2 + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/cross/1/end/2'), + ok( my $response = request('http://localhost/chained/cross/1/end/2'), 'cross controller w/o par/child relation' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -390,16 +390,16 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf::PassedArgs->first - TestApp::Controller::Action::ChildOf::PassedArgs->second - TestApp::Controller::Action::ChildOf::PassedArgs->third - TestApp::Controller::Action::ChildOf::PassedArgs->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained::PassedArgs->first + TestApp::Controller::Action::Chained::PassedArgs->second + TestApp::Controller::Action::Chained::PassedArgs->third + TestApp::Controller::Action::Chained::PassedArgs->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/passedargs/a/1/b/2/c/3'), + ok( my $response = request('http://localhost/chained/passedargs/a/1/b/2/c/3'), 'Correct arguments passed to actions' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -412,14 +412,14 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->opt_args - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->opt_args + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/opt_args/1/2/3'), + ok( my $response = request('http://localhost/chained/opt_args/1/2/3'), 'Optional :Args attribute working' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -431,15 +431,15 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->opt_pp_start - TestApp::Controller::Action::ChildOf->opt_pathpart - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->opt_pp_start + TestApp::Controller::Action::Chained->opt_pathpart + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/optpp/1/opt_pathpart/2'), + ok( my $response = request('http://localhost/chained/optpp/1/opt_pathpart/2'), 'Optional :PathName attribute working' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); @@ -451,15 +451,15 @@ sub run_tests { # { my @expected = qw[ - TestApp::Controller::Action::ChildOf->begin - TestApp::Controller::Action::ChildOf->opt_all_start - TestApp::Controller::Action::ChildOf->oa - TestApp::Controller::Action::ChildOf->end + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->opt_all_start + TestApp::Controller::Action::Chained->oa + TestApp::Controller::Action::Chained->end ]; my $expected = join( ", ", @expected ); - ok( my $response = request('http://localhost/childof/optall/1/oa/2/3'), + ok( my $response = request('http://localhost/chained/optall/1/oa/2/3'), 'Optional :PathName *and* :Args attributes working' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); diff --git a/t/unit_core_uri_for_action.t b/t/unit_core_uri_for_action.t index 99b4c51..4086139 100644 --- a/t/unit_core_uri_for_action.t +++ b/t/unit_core_uri_for_action.t @@ -56,19 +56,19 @@ is($dispatcher->uri_for_action($index_action), "/action/index", "index action returns correct path"); -my $childof_action = $dispatcher->get_action_by_path( - '/action/childof/endpoint', +my $chained_action = $dispatcher->get_action_by_path( + '/action/chained/endpoint', ); -ok(!defined($dispatcher->uri_for_action($childof_action)), - "ChildOf action without captures returns undef"); +ok(!defined($dispatcher->uri_for_action($chained_action)), + "Chained action without captures returns undef"); -ok(!defined($dispatcher->uri_for_action($childof_action, [ 1, 2 ])), - "ChildOf action with too many captures returns undef"); +ok(!defined($dispatcher->uri_for_action($chained_action, [ 1, 2 ])), + "Chained action with too many captures returns undef"); -is($dispatcher->uri_for_action($childof_action, [ 1 ]), - "/childof/foo/1/end", - "ChildOf action with correct captures returns correct path"); +is($dispatcher->uri_for_action($chained_action, [ 1 ]), + "/chained/foo/1/end", + "Chained action with correct captures returns correct path"); my $request = Catalyst::Request->new( { base => URI->new('http://127.0.0.1/foo') @@ -94,6 +94,6 @@ is($context->uri_for($regex_action, [ 'foo', 123 ], qw/bar baz/, { q => 1 }), "http://127.0.0.1/foo/action/regexp/foo/123/bar/baz?q=1", "uri_for correct for regex with captures, args and query"); -is($context->uri_for($childof_action, [ 1 ], 2, { q => 1 }), - "http://127.0.0.1/foo/childof/foo/1/end/2?q=1", - "uri_for correct for childof with captures, args and query"); +is($context->uri_for($chained_action, [ 1 ], 2, { q => 1 }), + "http://127.0.0.1/foo/chained/foo/1/end/2?q=1", + "uri_for correct for chained with captures, args and query");