use FindBin;
use lib "$FindBin::Bin/../../../lib";
-use Test::More tests => 14;
+our $iters;
+
+BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }
+
+use Test::More tests => 19*$iters;
use Catalyst::Test 'TestApp';
-
-for ( 1 .. 1 ) {
+
+if ( $ENV{CAT_BENCHMARK} ) {
+ require Benchmark;
+ Benchmark::timethis( $iters, \&run_tests );
+}
+else {
+ for ( 1 .. $iters ) {
+ run_tests();
+ }
+}
+
+sub run_tests {
# test root index
{
ok( my $response = request('http://localhost/'), 'root index' );
# test first-level controller index
{
- ok( my $response = request('http://localhost/action/'), 'first-level controller index' );
- is( $response->content, 'Action index', 'first-level controller index ok' );
+ my @expected = qw[
+ TestApp::Controller::Index->index
+ ];
+
+ my $expected = join( ", ", @expected );
- ok( $response = request('http://localhost/action'), 'first-level controller index no slash' );
- is( $response->content, 'Action index', 'first-level controller index no slash ok' );
+ ok( my $response = request('http://localhost/index/'), 'first-level controller index' );
+ is( $response->header('X-Catalyst-Executed'),
+ $expected, 'Executed actions' );
+ is( $response->content, 'Index index', 'first-level controller index ok' );
+
+ ok( $response = request('http://localhost/index'), 'first-level controller index no slash' );
+ is( $response->header('X-Catalyst-Executed'),
+ $expected, 'Executed actions' );
+ is( $response->content, 'Index index', 'first-level controller index no slash ok' );
}
# test second-level controller index
{
+ my @expected = qw[
+ TestApp::Controller::Action::Index->begin
+ TestApp::Controller::Action::Index->index
+ ];
+
+ my $expected = join( ", ", @expected );
+
ok( my $response = request('http://localhost/action/index/'), 'second-level controller index' );
- is( $response->content, 'Action::Index index', 'second-level controller index ok' );
+ is( $response->header('X-Catalyst-Executed'),
+ $expected, 'Executed actions' );
+ is( $response->content, 'Action-Index index', 'second-level controller index ok' );
ok( $response = request('http://localhost/action/index'), 'second-level controller index no slash' );
- is( $response->content, 'Action::Index index', 'second-level controller index no slash ok' );
+ is( $response->header('X-Catalyst-Executed'),
+ $expected, 'Executed actions' );
+ is( $response->content, 'Action-Index index', 'second-level controller index no slash ok' );
}
# test controller default when index is present
{
+ my @expected = qw[
+ TestApp::Controller::Action::Index->begin
+ TestApp::Controller::Action::Index->default
+ ];
+
+ my $expected = join( ", ", @expected );
+
ok( my $response = request('http://localhost/action/index/foo'), 'default with index' );
+ is( $response->header('X-Catalyst-Executed'),
+ $expected, 'Executed actions' );
is( $response->content, "Error - TestApp::Controller::Action\n", 'default with index ok' );
}
}