X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcomponent%2Fcontroller%2Faction%2Finheritance.t;fp=t%2Fcomponent%2Fcontroller%2Faction%2Finheritance.t;h=3bc6ebb871bf01d6ff19d4be7434d58e3d26bd7b;hb=ea80848dafeecc0b20864b0bc6c3d56d175647dd;hp=0000000000000000000000000000000000000000;hpb=3b242e4f5cd0924020a7db0622fd5f779f5bf8be;p=catagits%2FCatalyst-Runtime.git diff --git a/t/component/controller/action/inheritance.t b/t/component/controller/action/inheritance.t new file mode 100644 index 0000000..3bc6ebb --- /dev/null +++ b/t/component/controller/action/inheritance.t @@ -0,0 +1,74 @@ +#!perl + +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/../../lib"; + +use Test::More no_plan => 1; +use Catalyst::Test 'TestApp'; + + +{ + my @expected = qw[ + TestApp::Controller::Action::Inheritance->begin + TestApp::Controller::Action::Inheritance->auto + TestApp::Controller::Action::Inheritance->default + TestApp::View::Dump::Request->process + TestApp::Controller::Action::Inheritance->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/action/inheritance'), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' ); + is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Inheritance', 'Test Class' ); + is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); + like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' ); +} + +{ + my @expected = qw[ + TestApp::Controller::Action::Inheritance::A->begin + TestApp::Controller::Action::Inheritance->auto + TestApp::Controller::Action::Inheritance::A->auto + TestApp::Controller::Action::Inheritance::A->default + TestApp::View::Dump::Request->process + TestApp::Controller::Action::Inheritance::A->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/action/inheritance/a'), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' ); + is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Inheritance::A', 'Test Class' ); + is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); + like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' ); +} + +{ + my @expected = qw[ + TestApp::Controller::Action::Inheritance::A::B->begin + TestApp::Controller::Action::Inheritance->auto + TestApp::Controller::Action::Inheritance::A->auto + TestApp::Controller::Action::Inheritance::A::B->auto + TestApp::Controller::Action::Inheritance::A::B->default + TestApp::View::Dump::Request->process + TestApp::Controller::Action::Inheritance::A::B->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/action/inheritance/a/b'), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' ); + is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Inheritance::A::B', 'Test Class' ); + is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); + like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' ); +}