X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Faggregate%2Flive_component_controller_action_chained.t;h=0cebe9bfce1a4fa020a54a33bf02747dff472e91;hb=9434a81501df74c1bbe5745cc2bc3476213f2733;hp=20349df02b38712d6fd96dbb8986a9f3ec615058;hpb=055abad13cd2de549311b897e931d4c06d96d6fc;p=catagits%2FCatalyst-Runtime.git diff --git a/t/aggregate/live_component_controller_action_chained.t b/t/aggregate/live_component_controller_action_chained.t index 20349df..0cebe9b 100644 --- a/t/aggregate/live_component_controller_action_chained.t +++ b/t/aggregate/live_component_controller_action_chained.t @@ -11,6 +11,8 @@ our $iters; BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } use Test::More; +use URI; +use URI::QueryParam; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -771,6 +773,25 @@ sub run_tests { } # + # Test throwing an error in the middle of a chain. + # + { + my @expected = qw[ + TestApp::Controller::Action::Chained->begin + TestApp::Controller::Action::Chained->chain_die_a + TestApp::Controller::Action::Chained->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/chained/chain_die/1/end/2'), + "Break a chain in the middle" ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, 'FATAL ERROR: break in the middle of a chain', 'Content OK' ); + } + + # # Tests that an uri_for to a chained root index action # returns the right value. # @@ -865,12 +886,9 @@ sub run_tests { ok( my $response = request('http://localhost/chained/mult_nopp2/action'), "Complex path with multiple non-capturing pathparts" ); - TODO: { - local $TODO = 'Known bug'; is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); is( $response->content, '; ', 'Content OK' ); - } } # @@ -1111,11 +1129,29 @@ sub run_tests { ok( my $content = get('http://localhost/' . $path), 'request ' . $path . ' ok'); + my $exp = URI->new('http://localhost:3000' . $path); + my ($want) = $content =~ m{/chained/(.*)}; + my $got = URI->new('http://localhost:3000/chained/' . $want); # Just check that the path matches, as who the hell knows or cares # where the app is based (live tests etc) - ok( index($content, $path) > 1, 'uri can round trip through uri_for' ) + is $got->path, $exp->path, "uri $path can round trip through uri_for (path)" + or diag("Expected $path, got $content"); + is_deeply $got->query_form_hash, $exp->query_form_hash, "uri $path can round trip through uri_for (query)" or diag("Expected $path, got $content"); } + + # + # match_captures + # + { + + ok( my $response = request('http://localhost/chained/match_captures/foo/bar'), 'match_captures: falling through' ); + is($response->header('X-TestAppActionTestMatchCaptures'), 'fallthrough', 'match_captures: fell through'); + + ok($response = request('http://localhost/chained/match_captures/force/bar'), 'match_captures: *not* falling through' ); + is($response->header('X-TestAppActionTestMatchCaptures'), 'forcing', 'match_captures: forced'); + is($response->header('X-TestAppActionTestMatchCapturesHasRan'), 'yes', 'match_captures: actually ran'); + } } done_testing;