[Catalyst-commits] r6582 - in trunk/Catalyst-Runtime/t: .
lib/TestApp/Controller lib/TestApp/Controller/Action
lib/TestApp/Controller/Engine/Request
lib/TestApp/Controller/Engine/Response
bricas at dev.catalyst.perl.org
bricas at dev.catalyst.perl.org
Thu Jul 19 13:47:49 GMT 2007
Author: bricas
Date: 2007-07-19 13:47:48 +0100 (Thu, 19 Jul 2007)
New Revision: 6582
Modified:
trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Action/Detach.pm
trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Engine/Request/URI.pm
trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Engine/Response/Large.pm
trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Fork.pm
trunk/Catalyst-Runtime/t/live_component_controller_action_auto.t
trunk/Catalyst-Runtime/t/live_component_controller_action_begin.t
trunk/Catalyst-Runtime/t/live_component_controller_action_detach.t
trunk/Catalyst-Runtime/t/live_component_controller_action_index.t
trunk/Catalyst-Runtime/t/live_component_controller_args.t
trunk/Catalyst-Runtime/t/live_engine_request_uri.t
trunk/Catalyst-Runtime/t/live_engine_response_large.t
trunk/Catalyst-Runtime/t/optional_http-server-restart.t
trunk/Catalyst-Runtime/t/optional_stress.t
trunk/Catalyst-Runtime/t/optional_threads.t
trunk/Catalyst-Runtime/t/unit_controller_config.t
trunk/Catalyst-Runtime/t/unit_core_merge_config_hashes.t
trunk/Catalyst-Runtime/t/unit_core_mvc.t
trunk/Catalyst-Runtime/t/unit_core_path_to.t
trunk/Catalyst-Runtime/t/unit_load_catalyst_test.t
Log:
convert tabs to spaces and set unix line endings in t/*
Modified: trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Action/Detach.pm
===================================================================
--- trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Action/Detach.pm 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Action/Detach.pm 2007-07-19 12:47:48 UTC (rev 6582)
@@ -1,45 +1,45 @@
-package TestApp::Controller::Action::Detach;
-
-use strict;
-use base 'TestApp::Controller::Action';
-
-sub one : Local {
- my ( $self, $c ) = @_;
- $c->detach('two');
- $c->forward('error');
-}
-
-sub two : Private {
- my ( $self, $c ) = @_;
- $c->forward('TestApp::View::Dump::Request');
-}
-
-sub error : Local {
- my ( $self, $c ) = @_;
- $c->res->output('error');
-}
-
-sub path : Local {
- my ( $self, $c ) = @_;
- $c->detach('/action/detach/two');
- $c->forward('error');
-}
-
-sub with_args : Local {
- my ( $self, $c, $orig ) = @_;
- $c->detach( 'args', [qq/new/] );
-}
-
-sub with_method_and_args : Local {
- my ( $self, $c, $orig ) = @_;
- $c->detach( qw/TestApp::Controller::Action::Detach args/, [qq/new/] );
-}
-
-sub args : Local {
- my ( $self, $c, $val ) = @_;
- die "Expected argument 'new', got '$val'" unless $val eq 'new';
- die "passed argument does not match args" unless $val eq $c->req->args->[0];
- $c->res->body( $c->req->args->[0] );
-}
-
-1;
+package TestApp::Controller::Action::Detach;
+
+use strict;
+use base 'TestApp::Controller::Action';
+
+sub one : Local {
+ my ( $self, $c ) = @_;
+ $c->detach('two');
+ $c->forward('error');
+}
+
+sub two : Private {
+ my ( $self, $c ) = @_;
+ $c->forward('TestApp::View::Dump::Request');
+}
+
+sub error : Local {
+ my ( $self, $c ) = @_;
+ $c->res->output('error');
+}
+
+sub path : Local {
+ my ( $self, $c ) = @_;
+ $c->detach('/action/detach/two');
+ $c->forward('error');
+}
+
+sub with_args : Local {
+ my ( $self, $c, $orig ) = @_;
+ $c->detach( 'args', [qq/new/] );
+}
+
+sub with_method_and_args : Local {
+ my ( $self, $c, $orig ) = @_;
+ $c->detach( qw/TestApp::Controller::Action::Detach args/, [qq/new/] );
+}
+
+sub args : Local {
+ my ( $self, $c, $val ) = @_;
+ die "Expected argument 'new', got '$val'" unless $val eq 'new';
+ die "passed argument does not match args" unless $val eq $c->req->args->[0];
+ $c->res->body( $c->req->args->[0] );
+}
+
+1;
Modified: trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Engine/Request/URI.pm
===================================================================
--- trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Engine/Request/URI.pm 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Engine/Request/URI.pm 2007-07-19 12:47:48 UTC (rev 6582)
@@ -1,80 +1,80 @@
-package TestApp::Controller::Engine::Request::URI;
-
-use strict;
-use base 'Catalyst::Base';
-
-sub default : Private {
- my ( $self, $c ) = @_;
-
- $c->forward('TestApp::View::Dump::Request');
-}
-
-sub change_path : Local {
- my ( $self, $c ) = @_;
-
- # change the path
- $c->req->path( '/my/app/lives/here' );
-
- $c->forward('TestApp::View::Dump::Request');
-}
-
-sub change_base : Local {
- my ( $self, $c ) = @_;
-
- # change the base and uri paths
- $c->req->base->path( '/new/location' );
- $c->req->uri->path( '/new/location/engine/request/uri/change_base' );
-
- $c->forward('TestApp::View::Dump::Request');
-}
-
-sub uri_with : Local {
- my ( $self, $c ) = @_;
-
- # change the current uri
- my $uri = $c->req->uri_with( { b => 1 } );
- my %query = $uri->query_form;
-
- $c->res->header( 'X-Catalyst-Param-a' => $query{ a } );
- $c->res->header( 'X-Catalyst-Param-b' => $query{ b } );
-
- $c->forward('TestApp::View::Dump::Request');
-}
-
-sub uri_with_object : Local {
- my ( $self, $c ) = @_;
-
- my $uri = $c->req->uri_with( { a => $c->req->base } );
- my %query = $uri->query_form;
-
- $c->res->header( 'X-Catalyst-Param-a' => $query{ a } );
-
- $c->forward('TestApp::View::Dump::Request');
-}
-
-sub uri_with_utf8 : Local {
- my ( $self, $c ) = @_;
-
- # change the current uri
- my $uri = $c->req->uri_with( { unicode => "\x{2620}" } );
-
- $c->res->header( 'X-Catalyst-uri-with' => "$uri" );
-
- $c->forward('TestApp::View::Dump::Request');
-}
-
-sub uri_with_undef : Local {
- my ( $self, $c ) = @_;
+package TestApp::Controller::Engine::Request::URI;
+use strict;
+use base 'Catalyst::Base';
+
+sub default : Private {
+ my ( $self, $c ) = @_;
+
+ $c->forward('TestApp::View::Dump::Request');
+}
+
+sub change_path : Local {
+ my ( $self, $c ) = @_;
+
+ # change the path
+ $c->req->path( '/my/app/lives/here' );
+
+ $c->forward('TestApp::View::Dump::Request');
+}
+
+sub change_base : Local {
+ my ( $self, $c ) = @_;
+
+ # change the base and uri paths
+ $c->req->base->path( '/new/location' );
+ $c->req->uri->path( '/new/location/engine/request/uri/change_base' );
+
+ $c->forward('TestApp::View::Dump::Request');
+}
+
+sub uri_with : Local {
+ my ( $self, $c ) = @_;
+
+ # change the current uri
+ my $uri = $c->req->uri_with( { b => 1 } );
+ my %query = $uri->query_form;
+
+ $c->res->header( 'X-Catalyst-Param-a' => $query{ a } );
+ $c->res->header( 'X-Catalyst-Param-b' => $query{ b } );
+
+ $c->forward('TestApp::View::Dump::Request');
+}
+
+sub uri_with_object : Local {
+ my ( $self, $c ) = @_;
+
+ my $uri = $c->req->uri_with( { a => $c->req->base } );
+ my %query = $uri->query_form;
+
+ $c->res->header( 'X-Catalyst-Param-a' => $query{ a } );
+
+ $c->forward('TestApp::View::Dump::Request');
+}
+
+sub uri_with_utf8 : Local {
+ my ( $self, $c ) = @_;
+
+ # change the current uri
+ my $uri = $c->req->uri_with( { unicode => "\x{2620}" } );
+
+ $c->res->header( 'X-Catalyst-uri-with' => "$uri" );
+
+ $c->forward('TestApp::View::Dump::Request');
+}
+
+sub uri_with_undef : Local {
+ my ( $self, $c ) = @_;
+
my $warnings = 0;
- local $SIG{__WARN__} = sub { $warnings++ };
-
+ local $SIG{__WARN__} = sub { $warnings++ };
+
# change the current uri
- my $uri = $c->req->uri_with( { foo => undef } );
-
- $c->res->header( 'X-Catalyst-warnings' => $warnings );
-
- $c->forward('TestApp::View::Dump::Request');
-}
-
-1;
+ my $uri = $c->req->uri_with( { foo => undef } );
+
+ $c->res->header( 'X-Catalyst-warnings' => $warnings );
+
+ $c->forward('TestApp::View::Dump::Request');
+}
+
+1;
Modified: trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Engine/Response/Large.pm
===================================================================
--- trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Engine/Response/Large.pm 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Engine/Response/Large.pm 2007-07-19 12:47:48 UTC (rev 6582)
@@ -1,16 +1,16 @@
-package TestApp::Controller::Engine::Response::Large;
-
-use strict;
-use base 'Catalyst::Base';
-
-sub one : Relative {
- my ( $self, $c ) = @_;
- $c->res->output( 'x' x (100 * 1024) );
-}
-
-sub two : Relative {
- my ( $self, $c ) = @_;
- $c->res->output( 'y' x (1024 * 1024) );
-}
-
-1;
+package TestApp::Controller::Engine::Response::Large;
+
+use strict;
+use base 'Catalyst::Base';
+
+sub one : Relative {
+ my ( $self, $c ) = @_;
+ $c->res->output( 'x' x (100 * 1024) );
+}
+
+sub two : Relative {
+ my ( $self, $c ) = @_;
+ $c->res->output( 'y' x (1024 * 1024) );
+}
+
+1;
Modified: trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Fork.pm
===================================================================
--- trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Fork.pm 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/lib/TestApp/Controller/Fork.pm 2007-07-19 12:47:48 UTC (rev 6582)
@@ -14,11 +14,11 @@
my ($result, $code) = (undef, 1);
if(!-e $ls || !-x _){
- $result = 'skip';
+ $result = 'skip';
}
else {
- $result = system($ls, $ls, $ls);
- $result = $! if $result != 0;
+ $result = system($ls, $ls, $ls);
+ $result = $! if $result != 0;
}
$c->response->body(Dump({result => $result}));
@@ -29,12 +29,12 @@
my ($result, $code) = (undef, 1);
if(!-e $ls || !-x _){
- $result = 'skip';
- $code = 0;
+ $result = 'skip';
+ $code = 0;
}
else {
- $result = `$ls $ls $ls` || $!;
- $code = $?;
+ $result = `$ls $ls $ls` || $!;
+ $code = $?;
}
$c->response->body(Dump({result => $result, code => $code}));
@@ -46,10 +46,10 @@
my $x = 0;
if($pid = fork()){
- $x = "ok";
+ $x = "ok";
}
else {
- exit(0);
+ exit(0);
}
waitpid $pid,0 or die;
Modified: trunk/Catalyst-Runtime/t/live_component_controller_action_auto.t
===================================================================
--- trunk/Catalyst-Runtime/t/live_component_controller_action_auto.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/live_component_controller_action_auto.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -35,7 +35,7 @@
TestApp::Controller::Action::Auto->begin
TestApp::Controller::Action::Auto->auto
TestApp::Controller::Action::Auto->one
- TestApp->end
+ TestApp->end
];
my $expected = join( ", ", @expected );
@@ -52,7 +52,7 @@
TestApp::Controller::Action::Auto->begin
TestApp::Controller::Action::Auto->auto
TestApp::Controller::Action::Auto->default
- TestApp->end
+ TestApp->end
];
my $expected = join( ", ", @expected );
@@ -70,7 +70,7 @@
TestApp::Controller::Action::Auto->auto
TestApp::Controller::Action::Auto::Deep->auto
TestApp::Controller::Action::Auto::Deep->one
- TestApp->end
+ TestApp->end
];
my $expected = join( ", ", @expected );
@@ -88,7 +88,7 @@
TestApp::Controller::Action::Auto->auto
TestApp::Controller::Action::Auto::Deep->auto
TestApp::Controller::Action::Auto::Deep->default
- TestApp->end
+ TestApp->end
];
my $expected = join( ", ", @expected );
Modified: trunk/Catalyst-Runtime/t/live_component_controller_action_begin.t
===================================================================
--- trunk/Catalyst-Runtime/t/live_component_controller_action_begin.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/live_component_controller_action_begin.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -30,7 +30,7 @@
TestApp::Controller::Action::Begin->begin
TestApp::Controller::Action::Begin->default
TestApp::View::Dump::Request->process
- TestApp->end
+ TestApp->end
];
my $expected = join( ", ", @expected );
Modified: trunk/Catalyst-Runtime/t/live_component_controller_action_detach.t
===================================================================
--- trunk/Catalyst-Runtime/t/live_component_controller_action_detach.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/live_component_controller_action_detach.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -1,100 +1,100 @@
-#!perl
-
-use strict;
-use warnings;
-
-use FindBin;
-use lib "$FindBin::Bin/lib";
-
-our $iters;
-
-BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
-
-use Test::More tests => 18*$iters;
-use Catalyst::Test 'TestApp';
-
-if ( $ENV{CAT_BENCHMARK} ) {
- require Benchmark;
- Benchmark::timethis( $iters, \&run_tests );
-}
-else {
- for ( 1 .. $iters ) {
- run_tests();
- }
-}
-
-sub run_tests {
- {
- my @expected = qw[
- TestApp::Controller::Action::Detach->begin
- TestApp::Controller::Action::Detach->one
- TestApp::Controller::Action::Detach->two
- TestApp::View::Dump::Request->process
- TestApp->end
- ];
-
- my $expected = join( ", ", @expected );
-
- # Test detach to chain of actions.
- ok( my $response = request('http://localhost/action/detach/one'),
- 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
- is( $response->content_type, 'text/plain', 'Response Content-Type' );
- is( $response->header('X-Catalyst-Action'),
- 'action/detach/one', 'Test Action' );
- is(
- $response->header('X-Test-Class'),
- 'TestApp::Controller::Action::Detach',
- 'Test Class'
- );
- is( $response->header('X-Catalyst-Executed'),
- $expected, 'Executed actions' );
- }
-
- {
- my @expected = qw[
- TestApp::Controller::Action::Detach->begin
- TestApp::Controller::Action::Detach->path
- TestApp::Controller::Action::Detach->two
- TestApp::View::Dump::Request->process
- TestApp->end
- ];
-
- my $expected = join( ", ", @expected );
-
- # Test detach to chain of actions.
- ok( my $response = request('http://localhost/action/detach/path'),
- 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
- is( $response->content_type, 'text/plain', 'Response Content-Type' );
- is( $response->header('X-Catalyst-Action'),
- 'action/detach/path', 'Test Action' );
- is(
- $response->header('X-Test-Class'),
- 'TestApp::Controller::Action::Detach',
- 'Test Class'
- );
- is( $response->header('X-Catalyst-Executed'),
- $expected, 'Executed actions' );
- }
-
- {
- ok(
- my $response =
- request('http://localhost/action/detach/with_args/old'),
- 'Request with args'
- );
- ok( $response->is_success, 'Response Successful 2xx' );
- is( $response->content, 'new' );
- }
-
- {
- ok(
- my $response = request(
- 'http://localhost/action/detach/with_method_and_args/old'),
- 'Request with args and method'
- );
- ok( $response->is_success, 'Response Successful 2xx' );
- is( $response->content, 'new' );
- }
-}
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+our $iters;
+
+BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
+
+use Test::More tests => 18*$iters;
+use Catalyst::Test 'TestApp';
+
+if ( $ENV{CAT_BENCHMARK} ) {
+ require Benchmark;
+ Benchmark::timethis( $iters, \&run_tests );
+}
+else {
+ for ( 1 .. $iters ) {
+ run_tests();
+ }
+}
+
+sub run_tests {
+ {
+ my @expected = qw[
+ TestApp::Controller::Action::Detach->begin
+ TestApp::Controller::Action::Detach->one
+ TestApp::Controller::Action::Detach->two
+ TestApp::View::Dump::Request->process
+ TestApp->end
+ ];
+
+ my $expected = join( ", ", @expected );
+
+ # Test detach to chain of actions.
+ ok( my $response = request('http://localhost/action/detach/one'),
+ 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content_type, 'text/plain', 'Response Content-Type' );
+ is( $response->header('X-Catalyst-Action'),
+ 'action/detach/one', 'Test Action' );
+ is(
+ $response->header('X-Test-Class'),
+ 'TestApp::Controller::Action::Detach',
+ 'Test Class'
+ );
+ is( $response->header('X-Catalyst-Executed'),
+ $expected, 'Executed actions' );
+ }
+
+ {
+ my @expected = qw[
+ TestApp::Controller::Action::Detach->begin
+ TestApp::Controller::Action::Detach->path
+ TestApp::Controller::Action::Detach->two
+ TestApp::View::Dump::Request->process
+ TestApp->end
+ ];
+
+ my $expected = join( ", ", @expected );
+
+ # Test detach to chain of actions.
+ ok( my $response = request('http://localhost/action/detach/path'),
+ 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content_type, 'text/plain', 'Response Content-Type' );
+ is( $response->header('X-Catalyst-Action'),
+ 'action/detach/path', 'Test Action' );
+ is(
+ $response->header('X-Test-Class'),
+ 'TestApp::Controller::Action::Detach',
+ 'Test Class'
+ );
+ is( $response->header('X-Catalyst-Executed'),
+ $expected, 'Executed actions' );
+ }
+
+ {
+ ok(
+ my $response =
+ request('http://localhost/action/detach/with_args/old'),
+ 'Request with args'
+ );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content, 'new' );
+ }
+
+ {
+ ok(
+ my $response = request(
+ 'http://localhost/action/detach/with_method_and_args/old'),
+ 'Request with args and method'
+ );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content, 'new' );
+ }
+}
Modified: trunk/Catalyst-Runtime/t/live_component_controller_action_index.t
===================================================================
--- trunk/Catalyst-Runtime/t/live_component_controller_action_index.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/live_component_controller_action_index.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -87,7 +87,7 @@
my @expected = qw[
TestApp::Controller::Action::Index->begin
TestApp::Controller::Action::Index->default
- TestApp->end
+ TestApp->end
];
my $expected = join( ", ", @expected );
Modified: trunk/Catalyst-Runtime/t/live_component_controller_args.t
===================================================================
--- trunk/Catalyst-Runtime/t/live_component_controller_args.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/live_component_controller_args.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -13,21 +13,21 @@
BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1;
- # add special paths to test here
- @paths = (
- # all reserved in uri's
- qw~ : / ? [ ] @ ! $ & ' ( ) * + ; = ~, ',' , '#',
+ # add special paths to test here
+ @paths = (
+ # all reserved in uri's
+ qw~ : / ? [ ] @ ! $ & ' ( ) * + ; = ~, ',' , '#',
- # unreserved
- 'a'..'z','A'..'Z',0..9,qw( - . _ ~ ),
- " ",
+ # unreserved
+ 'a'..'z','A'..'Z',0..9,qw( - . _ ~ ),
+ " ",
- # just to test %2F/%
- [ qw~ / / ~ ],
+ # just to test %2F/%
+ [ qw~ / / ~ ],
- # testing %25/%25
- [ qw~ % % ~ ],
- );
+ # testing %25/%25
+ [ qw~ % % ~ ],
+ );
}
use Test::More tests => 6*@paths * $iters;
Modified: trunk/Catalyst-Runtime/t/live_engine_request_uri.t
===================================================================
--- trunk/Catalyst-Runtime/t/live_engine_request_uri.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/live_engine_request_uri.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -1,106 +1,106 @@
-#!perl
-
-use strict;
-use warnings;
-
-use FindBin;
-use lib "$FindBin::Bin/lib";
-
-use Test::More tests => 44;
-use Catalyst::Test 'TestApp';
-use Catalyst::Request;
-
-my $creq;
-
-# test that the path can be changed
-{
- ok( my $response = request('http://localhost/engine/request/uri/change_path'), 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
- ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
- like( $creq->uri, qr{/my/app/lives/here$}, 'URI contains new path' );
-}
-
-# test that path properly removes the base location
-{
- ok( my $response = request('http://localhost/engine/request/uri/change_base'), 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
- ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
- like( $creq->base, qr{/new/location}, 'Base URI contains new location' );
- is( $creq->path, 'engine/request/uri/change_base', 'URI contains correct path' );
-}
-
-# test that base + path is correct
-{
- ok( my $response = request('http://localhost/engine/request/uri'), 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
- ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
- is( $creq->base . $creq->path, $creq->uri, 'Base + Path ok' );
-}
-
-# test that we can use semi-colons as separators
-{
- my $parameters = {
- a => [ qw/1 2/ ],
- b => 3,
- };
-
- ok( my $response = request('http://localhost/engine/request/uri?a=1;a=2;b=3'), 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
- ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
- is( $creq->{uri}->query, 'a=1;a=2;b=3', 'Query string ok' );
- is_deeply( $creq->{parameters}, $parameters, 'Parameters ok' );
-}
-
-# test that query params are unescaped properly
-{
- ok( my $response = request('http://localhost/engine/request/uri?text=Catalyst%20Rocks'), 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
- ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
- is( $creq->{uri}->query, 'text=Catalyst%20Rocks', 'Query string ok' );
- is( $creq->{parameters}->{text}, 'Catalyst Rocks', 'Unescaped param ok' );
-}
-
-# test that uri_with adds params
-{
- ok( my $response = request('http://localhost/engine/request/uri/uri_with'), 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
- ok( !defined $response->header( 'X-Catalyst-Param-a' ), 'param "a" ok' );
- is( $response->header( 'X-Catalyst-Param-b' ), '1', 'param "b" ok' );
-}
-
-# test that uri_with adds params (and preserves)
-{
- ok( my $response = request('http://localhost/engine/request/uri/uri_with?a=1'), 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
- is( $response->header( 'X-Catalyst-Param-a' ), '1', 'param "a" ok' );
- is( $response->header( 'X-Catalyst-Param-b' ), '1', 'param "b" ok' );
-}
-
-# test that uri_with replaces params (and preserves)
-{
- ok( my $response = request('http://localhost/engine/request/uri/uri_with?a=1&b=2'), 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
- is( $response->header( 'X-Catalyst-Param-a' ), '1', 'param "a" ok' );
- is( $response->header( 'X-Catalyst-Param-b' ), '1', 'param "b" ok' );
-}
-
-# test that uri_with replaces params (and preserves)
-{
- ok( my $response = request('http://localhost/engine/request/uri/uri_with_object'), 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
- like( $response->header( 'X-Catalyst-Param-a' ), qr(http://localhost[^/]*/), 'param "a" ok' );
-}
-
-# test that uri_with is utf8 safe
-{
- ok( my $response = request("http://localhost/engine/request/uri/uri_with_utf8"), 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
- like( $response->header( 'X-Catalyst-uri-with' ), qr/%E2%98%A0$/, 'uri_with ok' );
-}
+#!perl
-# test with undef -- no warnings should be thrown
-{
- ok( my $response = request("http://localhost/engine/request/uri/uri_with_undef"), 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
- is( $response->header( 'X-Catalyst-warnings' ), 0, 'no warnings emitted' );
-}
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More tests => 44;
+use Catalyst::Test 'TestApp';
+use Catalyst::Request;
+
+my $creq;
+
+# test that the path can be changed
+{
+ ok( my $response = request('http://localhost/engine/request/uri/change_path'), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
+ like( $creq->uri, qr{/my/app/lives/here$}, 'URI contains new path' );
+}
+
+# test that path properly removes the base location
+{
+ ok( my $response = request('http://localhost/engine/request/uri/change_base'), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
+ like( $creq->base, qr{/new/location}, 'Base URI contains new location' );
+ is( $creq->path, 'engine/request/uri/change_base', 'URI contains correct path' );
+}
+
+# test that base + path is correct
+{
+ ok( my $response = request('http://localhost/engine/request/uri'), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
+ is( $creq->base . $creq->path, $creq->uri, 'Base + Path ok' );
+}
+
+# test that we can use semi-colons as separators
+{
+ my $parameters = {
+ a => [ qw/1 2/ ],
+ b => 3,
+ };
+
+ ok( my $response = request('http://localhost/engine/request/uri?a=1;a=2;b=3'), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
+ is( $creq->{uri}->query, 'a=1;a=2;b=3', 'Query string ok' );
+ is_deeply( $creq->{parameters}, $parameters, 'Parameters ok' );
+}
+
+# test that query params are unescaped properly
+{
+ ok( my $response = request('http://localhost/engine/request/uri?text=Catalyst%20Rocks'), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
+ is( $creq->{uri}->query, 'text=Catalyst%20Rocks', 'Query string ok' );
+ is( $creq->{parameters}->{text}, 'Catalyst Rocks', 'Unescaped param ok' );
+}
+
+# test that uri_with adds params
+{
+ ok( my $response = request('http://localhost/engine/request/uri/uri_with'), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ ok( !defined $response->header( 'X-Catalyst-Param-a' ), 'param "a" ok' );
+ is( $response->header( 'X-Catalyst-Param-b' ), '1', 'param "b" ok' );
+}
+
+# test that uri_with adds params (and preserves)
+{
+ ok( my $response = request('http://localhost/engine/request/uri/uri_with?a=1'), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->header( 'X-Catalyst-Param-a' ), '1', 'param "a" ok' );
+ is( $response->header( 'X-Catalyst-Param-b' ), '1', 'param "b" ok' );
+}
+
+# test that uri_with replaces params (and preserves)
+{
+ ok( my $response = request('http://localhost/engine/request/uri/uri_with?a=1&b=2'), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->header( 'X-Catalyst-Param-a' ), '1', 'param "a" ok' );
+ is( $response->header( 'X-Catalyst-Param-b' ), '1', 'param "b" ok' );
+}
+
+# test that uri_with replaces params (and preserves)
+{
+ ok( my $response = request('http://localhost/engine/request/uri/uri_with_object'), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ like( $response->header( 'X-Catalyst-Param-a' ), qr(http://localhost[^/]*/), 'param "a" ok' );
+}
+
+# test that uri_with is utf8 safe
+{
+ ok( my $response = request("http://localhost/engine/request/uri/uri_with_utf8"), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ like( $response->header( 'X-Catalyst-uri-with' ), qr/%E2%98%A0$/, 'uri_with ok' );
+}
+
+# test with undef -- no warnings should be thrown
+{
+ ok( my $response = request("http://localhost/engine/request/uri/uri_with_undef"), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->header( 'X-Catalyst-warnings' ), 0, 'no warnings emitted' );
+}
Modified: trunk/Catalyst-Runtime/t/live_engine_response_large.t
===================================================================
--- trunk/Catalyst-Runtime/t/live_engine_response_large.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/live_engine_response_large.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -1,27 +1,27 @@
-#!perl
-
-use strict;
-use warnings;
-
-use FindBin;
-use lib "$FindBin::Bin/lib";
-
-use Test::More tests => 6;
-use Catalyst::Test 'TestApp';
-
-# phaylon noticed that refactored was truncating output on large images.
-# This test tests 100K and 1M output content.
-
-my $expected = {
- one => 'x' x (100 * 1024),
- two => 'y' x (1024 * 1024),
-};
-
-for my $action ( keys %{$expected} ) {
- ok( my $response = request('http://localhost/engine/response/large/' . $action ),
- 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
-
- is( length( $response->content ), length( $expected->{$action} ), 'Length OK' );
-}
-
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More tests => 6;
+use Catalyst::Test 'TestApp';
+
+# phaylon noticed that refactored was truncating output on large images.
+# This test tests 100K and 1M output content.
+
+my $expected = {
+ one => 'x' x (100 * 1024),
+ two => 'y' x (1024 * 1024),
+};
+
+for my $action ( keys %{$expected} ) {
+ ok( my $response = request('http://localhost/engine/response/large/' . $action ),
+ 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+
+ is( length( $response->content ), length( $expected->{$action} ), 'Length OK' );
+}
+
Modified: trunk/Catalyst-Runtime/t/optional_http-server-restart.t
===================================================================
--- trunk/Catalyst-Runtime/t/optional_http-server-restart.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/optional_http-server-restart.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -1,121 +1,121 @@
-#!perl
-
-# This test tests the standalone server's auto-restart feature.
-
-use strict;
-use warnings;
-
-use File::Path;
-use FindBin;
-use LWP::Simple;
-use IO::Socket;
-use Test::More;
-use Time::HiRes qw/sleep/;
-eval "use Catalyst::Devel 1.0;";
-
-plan skip_all => 'set TEST_HTTP to enable this test' unless $ENV{TEST_HTTP};
-plan skip_all => 'Catalyst::Devel required' if $@;
-eval "use File::Copy::Recursive";
-plan skip_all => 'File::Copy::Recursive required' if $@;
-
-plan tests => 40;
-
-# clean up
-rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
-
-# create a TestApp and copy the test libs into it
-mkdir "$FindBin::Bin/../t/tmp";
-chdir "$FindBin::Bin/../t/tmp";
-system
- "perl -I$FindBin::Bin/../lib $FindBin::Bin/../script/catalyst.pl TestApp";
-chdir "$FindBin::Bin/..";
-File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
-
-# remove TestApp's tests
-rmtree 't/tmp/TestApp/t';
-
-# spawn the standalone HTTP server
-my $port = 30000 + int rand( 1 + 10000 );
-my $pid = open my $server,
-"perl -I$FindBin::Bin/../lib $FindBin::Bin/../t/tmp/TestApp/script/testapp_server.pl -port $port -restart 2>&1 |"
- or die "Unable to spawn standalone HTTP server: $!";
-
-# wait for it to start
-print "Waiting for server to start...\n";
-while ( check_port( 'localhost', $port ) != 1 ) {
- sleep 1;
-}
-
-# change various files
-my @files = (
- "$FindBin::Bin/../t/tmp/TestApp/lib/TestApp.pm",
- "$FindBin::Bin/../t/tmp/TestApp/lib/TestApp/Controller/Action/Begin.pm",
-"$FindBin::Bin/../t/tmp/TestApp/lib/TestApp/Controller/Engine/Request/URI.pm",
-);
-
-# change some files and make sure the server restarts itself
-for ( 1 .. 20 ) {
- my $index = rand @files;
- open my $pm, '>>', $files[$index]
- or die "Unable to open $files[$index] for writing: $!";
- print $pm "\n";
- close $pm;
-
- # give the server time to notice the change and restart
- my $count = 0;
- sleep 1;
- while ( check_port( 'localhost', $port ) != 1 ) {
-
- # wait for it to restart
- sleep 0.1;
- die "Server appears to have died" if $count++ > 50;
- }
- my $response = get("http://localhost:$port/action/default");
- like( $response, qr/Catalyst::Request/, 'Non-error restart, request OK' );
-
- #print $server->getline;
-}
-
-# add errors to the file and make sure server does not die or restart
-for ( 1 .. 20 ) {
- my $index = rand @files;
- open my $pm, '>>', $files[$index]
- or die "Unable to open $files[$index] for writing: $!";
- print $pm "bleh";
- close $pm;
-
- # give the server time to notice the change
- sleep 1;
- if ( check_port( 'localhost', $port ) != 1 ) {
- die "Server appears to have died";
- }
- my $response = get("http://localhost:$port/action/default");
- like( $response, qr/Catalyst::Request/,
- 'Syntax error, no restart, request OK' );
-
- #print $server->getline;
-}
-
-# shut it down
-kill 'INT', $pid;
-close $server;
-
-# clean up
-rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
-
-sub check_port {
- my ( $host, $port ) = @_;
-
- my $remote = IO::Socket::INET->new(
- Proto => "tcp",
- PeerAddr => $host,
- PeerPort => $port
- );
- if ($remote) {
- close $remote;
- return 1;
- }
- else {
- return 0;
- }
-}
+#!perl
+
+# This test tests the standalone server's auto-restart feature.
+
+use strict;
+use warnings;
+
+use File::Path;
+use FindBin;
+use LWP::Simple;
+use IO::Socket;
+use Test::More;
+use Time::HiRes qw/sleep/;
+eval "use Catalyst::Devel 1.0;";
+
+plan skip_all => 'set TEST_HTTP to enable this test' unless $ENV{TEST_HTTP};
+plan skip_all => 'Catalyst::Devel required' if $@;
+eval "use File::Copy::Recursive";
+plan skip_all => 'File::Copy::Recursive required' if $@;
+
+plan tests => 40;
+
+# clean up
+rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
+
+# create a TestApp and copy the test libs into it
+mkdir "$FindBin::Bin/../t/tmp";
+chdir "$FindBin::Bin/../t/tmp";
+system
+ "perl -I$FindBin::Bin/../lib $FindBin::Bin/../script/catalyst.pl TestApp";
+chdir "$FindBin::Bin/..";
+File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
+
+# remove TestApp's tests
+rmtree 't/tmp/TestApp/t';
+
+# spawn the standalone HTTP server
+my $port = 30000 + int rand( 1 + 10000 );
+my $pid = open my $server,
+"perl -I$FindBin::Bin/../lib $FindBin::Bin/../t/tmp/TestApp/script/testapp_server.pl -port $port -restart 2>&1 |"
+ or die "Unable to spawn standalone HTTP server: $!";
+
+# wait for it to start
+print "Waiting for server to start...\n";
+while ( check_port( 'localhost', $port ) != 1 ) {
+ sleep 1;
+}
+
+# change various files
+my @files = (
+ "$FindBin::Bin/../t/tmp/TestApp/lib/TestApp.pm",
+ "$FindBin::Bin/../t/tmp/TestApp/lib/TestApp/Controller/Action/Begin.pm",
+"$FindBin::Bin/../t/tmp/TestApp/lib/TestApp/Controller/Engine/Request/URI.pm",
+);
+
+# change some files and make sure the server restarts itself
+for ( 1 .. 20 ) {
+ my $index = rand @files;
+ open my $pm, '>>', $files[$index]
+ or die "Unable to open $files[$index] for writing: $!";
+ print $pm "\n";
+ close $pm;
+
+ # give the server time to notice the change and restart
+ my $count = 0;
+ sleep 1;
+ while ( check_port( 'localhost', $port ) != 1 ) {
+
+ # wait for it to restart
+ sleep 0.1;
+ die "Server appears to have died" if $count++ > 50;
+ }
+ my $response = get("http://localhost:$port/action/default");
+ like( $response, qr/Catalyst::Request/, 'Non-error restart, request OK' );
+
+ #print $server->getline;
+}
+
+# add errors to the file and make sure server does not die or restart
+for ( 1 .. 20 ) {
+ my $index = rand @files;
+ open my $pm, '>>', $files[$index]
+ or die "Unable to open $files[$index] for writing: $!";
+ print $pm "bleh";
+ close $pm;
+
+ # give the server time to notice the change
+ sleep 1;
+ if ( check_port( 'localhost', $port ) != 1 ) {
+ die "Server appears to have died";
+ }
+ my $response = get("http://localhost:$port/action/default");
+ like( $response, qr/Catalyst::Request/,
+ 'Syntax error, no restart, request OK' );
+
+ #print $server->getline;
+}
+
+# shut it down
+kill 'INT', $pid;
+close $server;
+
+# clean up
+rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
+
+sub check_port {
+ my ( $host, $port ) = @_;
+
+ my $remote = IO::Socket::INET->new(
+ Proto => "tcp",
+ PeerAddr => $host,
+ PeerPort => $port
+ );
+ if ($remote) {
+ close $remote;
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
Modified: trunk/Catalyst-Runtime/t/optional_stress.t
===================================================================
--- trunk/Catalyst-Runtime/t/optional_stress.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/optional_stress.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -1,37 +1,37 @@
-#!perl
-
-use strict;
-use warnings;
-
-use FindBin;
-use lib "$FindBin::Bin/lib";
-
-use Test::More;
-use Catalyst::Test 'TestApp';
-use YAML;
-
-our ( $iters, $tests );
-
-BEGIN {
- plan skip_all => 'set TEST_STRESS to enable this test'
- unless $ENV{TEST_STRESS};
-
- $iters = $ENV{TEST_STRESS} || 10;
- $tests = YAML::LoadFile("$FindBin::Bin/optional_stress.yml");
-
- my $total_tests = 0;
- map { $total_tests += scalar @{ $tests->{$_} } } keys %{$tests};
- plan tests => $iters * $total_tests;
-}
-
-for ( 1 .. $iters ) {
- run_tests();
-}
-
-sub run_tests {
- foreach my $test_group ( keys %{$tests} ) {
- foreach my $test ( @{ $tests->{$test_group} } ) {
- ok( request($test), $test_group . ' - ' . $test );
- }
- }
-}
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More;
+use Catalyst::Test 'TestApp';
+use YAML;
+
+our ( $iters, $tests );
+
+BEGIN {
+ plan skip_all => 'set TEST_STRESS to enable this test'
+ unless $ENV{TEST_STRESS};
+
+ $iters = $ENV{TEST_STRESS} || 10;
+ $tests = YAML::LoadFile("$FindBin::Bin/optional_stress.yml");
+
+ my $total_tests = 0;
+ map { $total_tests += scalar @{ $tests->{$_} } } keys %{$tests};
+ plan tests => $iters * $total_tests;
+}
+
+for ( 1 .. $iters ) {
+ run_tests();
+}
+
+sub run_tests {
+ foreach my $test_group ( keys %{$tests} ) {
+ foreach my $test ( @{ $tests->{$test_group} } ) {
+ ok( request($test), $test_group . ' - ' . $test );
+ }
+ }
+}
Modified: trunk/Catalyst-Runtime/t/optional_threads.t
===================================================================
--- trunk/Catalyst-Runtime/t/optional_threads.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/optional_threads.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -1,54 +1,54 @@
-#!perl
-
-use strict;
-use warnings;
-
-use FindBin;
-use lib "$FindBin::Bin/lib";
-
-use Test::More;
-use Catalyst::Test 'TestApp';
-use Catalyst::Request;
-use Config;
-use HTTP::Response;
-
-plan skip_all => 'set TEST_THREADS to enable this test'
- unless $ENV{TEST_THREADS};
-
-if ( $Config{useithreads} && !$ENV{CATALYST_SERVER} ) {
- require threads;
- plan tests => 3;
-}
-else {
- if ( $ENV{CATALYST_SERVER} ) {
- plan skip_all => 'Using remote server';
- }
- else {
- plan skip_all => 'Needs a Perl with ithreads enabled';
- }
-}
-
-no warnings 'redefine';
-sub request {
- my $thr = threads->new(
- sub { Catalyst::Test::local_request('TestApp', at _) },
- @_
- );
- $thr->join;
-}
-
-# test that running inside a thread works ok
-{
- my @expected = qw[
- TestApp::Controller::Action::Default->begin
- TestApp::Controller::Action::Default->default
- TestApp::View::Dump::Request->process
- TestApp->end
- ];
-
- my $expected = join( ", ", @expected );
-
- ok( my $response = request('http://localhost/action/default'), 'Request' );
- ok( $response->is_success, 'Response Successful 2xx' );
- is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );
-}
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More;
+use Catalyst::Test 'TestApp';
+use Catalyst::Request;
+use Config;
+use HTTP::Response;
+
+plan skip_all => 'set TEST_THREADS to enable this test'
+ unless $ENV{TEST_THREADS};
+
+if ( $Config{useithreads} && !$ENV{CATALYST_SERVER} ) {
+ require threads;
+ plan tests => 3;
+}
+else {
+ if ( $ENV{CATALYST_SERVER} ) {
+ plan skip_all => 'Using remote server';
+ }
+ else {
+ plan skip_all => 'Needs a Perl with ithreads enabled';
+ }
+}
+
+no warnings 'redefine';
+sub request {
+ my $thr = threads->new(
+ sub { Catalyst::Test::local_request('TestApp', at _) },
+ @_
+ );
+ $thr->join;
+}
+
+# test that running inside a thread works ok
+{
+ my @expected = qw[
+ TestApp::Controller::Action::Default->begin
+ TestApp::Controller::Action::Default->default
+ TestApp::View::Dump::Request->process
+ TestApp->end
+ ];
+
+ my $expected = join( ", ", @expected );
+
+ ok( my $response = request('http://localhost/action/default'), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );
+}
Modified: trunk/Catalyst-Runtime/t/unit_controller_config.t
===================================================================
--- trunk/Catalyst-Runtime/t/unit_controller_config.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/unit_controller_config.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -1,91 +1,91 @@
-## ============================================================================
-## Test to make sure that subclassed controllers (catalyst controllers
-## that inherit from a custom base catalyst controller) don't experienc
-## any namespace collision in the values under config.
-## ============================================================================
-
-use Test::More tests => 9;
-
-use strict;
-use warnings;
-
-use_ok('Catalyst');
-
-## ----------------------------------------------------------------------------
-## First We define a base controller that inherits from Catalyst::Controller
-## We add something to the config that we expect all children classes to
-## be able to find.
-## ----------------------------------------------------------------------------
-
-{
- package base_controller;
-
- use base 'Catalyst::Controller';
-
- __PACKAGE__->config( base_key => 'base_value' );
-}
-
-## ----------------------------------------------------------------------------
-## Next we instantiate two classes that inherit from the base controller. We
-## Add some local config information to these.
-## ----------------------------------------------------------------------------
-
-{
- package controller_a;
-
- use base 'base_controller';
-
- __PACKAGE__->config( key_a => 'value_a' );
-}
-
-
-{
- package controller_b;
-
- use base 'base_controller';
-
- __PACKAGE__->config( key_b => 'value_b' );
-}
-
-## Okay, we expect that the base controller has a config with one key
-## and that the two children controllers inherit that config key and then
-## add one more. So the base controller has one config value and the two
-## children each have two.
-
-## ----------------------------------------------------------------------------
-## THE TESTS. Basically we first check to make sure that all the children of
-## the base_controller properly inherit the {base_key => 'base_value'} info
-## and that each of the children also has it's local config data and that none
-## of the classes have data that is unexpected.
-## ----------------------------------------------------------------------------
-
-
-# First round, does everything have what we expect to find? If these tests fail there is something
-# wrong with the way config is storing it's information.
-
-ok( base_controller->config->{base_key} eq 'base_value', 'base_controller has expected config value for "base_key"') or
- diag('"base_key" defined as "'.base_controller->config->{base_key}.'" and not "base_value" in config');
-
-ok( controller_a->config->{base_key} eq 'base_value', 'controller_a has expected config value for "base_key"') or
- diag('"base_key" defined as "'.controller_a->config->{base_key}.'" and not "base_value" in config');
-
-ok( controller_a->config->{key_a} eq 'value_a', 'controller_a has expected config value for "key_a"') or
- diag('"key_a" defined as "'.controller_a->config->{key_a}.'" and not "value_a" in config');
-
-ok( controller_b->config->{base_key} eq 'base_value', 'controller_b has expected config value for "base_key"') or
- diag('"base_key" defined as "'.controller_b->config->{base_key}.'" and not "base_value" in config');
-
-ok( controller_b->config->{key_b} eq 'value_b', 'controller_b has expected config value for "key_b"') or
- diag('"key_b" defined as "'.controller_b->config->{key_b}.'" and not "value_b" in config');
-
-# second round, does each controller have the expected number of config values? If this test fails there is
-# probably some data collision between the controllers.
-
-ok( scalar(keys %{base_controller->config}) == 1, 'base_controller has the expected number of config values') or
- diag("base_controller should have 1 config value, but it has ".scalar(keys %{base_controller->config}));
-
-ok( scalar(keys %{controller_a->config}) == 2, 'controller_a has the expected number of config values') or
- diag("controller_a should have 2 config value, but it has ".scalar(keys %{base_controller->config}));
-
-ok( scalar(keys %{controller_b->config}) == 2, 'controller_b has the expected number of config values') or
- diag("controller_a should have 2 config value, but it has ".scalar(keys %{base_controller->config}));
+## ============================================================================
+## Test to make sure that subclassed controllers (catalyst controllers
+## that inherit from a custom base catalyst controller) don't experienc
+## any namespace collision in the values under config.
+## ============================================================================
+
+use Test::More tests => 9;
+
+use strict;
+use warnings;
+
+use_ok('Catalyst');
+
+## ----------------------------------------------------------------------------
+## First We define a base controller that inherits from Catalyst::Controller
+## We add something to the config that we expect all children classes to
+## be able to find.
+## ----------------------------------------------------------------------------
+
+{
+ package base_controller;
+
+ use base 'Catalyst::Controller';
+
+ __PACKAGE__->config( base_key => 'base_value' );
+}
+
+## ----------------------------------------------------------------------------
+## Next we instantiate two classes that inherit from the base controller. We
+## Add some local config information to these.
+## ----------------------------------------------------------------------------
+
+{
+ package controller_a;
+
+ use base 'base_controller';
+
+ __PACKAGE__->config( key_a => 'value_a' );
+}
+
+
+{
+ package controller_b;
+
+ use base 'base_controller';
+
+ __PACKAGE__->config( key_b => 'value_b' );
+}
+
+## Okay, we expect that the base controller has a config with one key
+## and that the two children controllers inherit that config key and then
+## add one more. So the base controller has one config value and the two
+## children each have two.
+
+## ----------------------------------------------------------------------------
+## THE TESTS. Basically we first check to make sure that all the children of
+## the base_controller properly inherit the {base_key => 'base_value'} info
+## and that each of the children also has it's local config data and that none
+## of the classes have data that is unexpected.
+## ----------------------------------------------------------------------------
+
+
+# First round, does everything have what we expect to find? If these tests fail there is something
+# wrong with the way config is storing it's information.
+
+ok( base_controller->config->{base_key} eq 'base_value', 'base_controller has expected config value for "base_key"') or
+ diag('"base_key" defined as "'.base_controller->config->{base_key}.'" and not "base_value" in config');
+
+ok( controller_a->config->{base_key} eq 'base_value', 'controller_a has expected config value for "base_key"') or
+ diag('"base_key" defined as "'.controller_a->config->{base_key}.'" and not "base_value" in config');
+
+ok( controller_a->config->{key_a} eq 'value_a', 'controller_a has expected config value for "key_a"') or
+ diag('"key_a" defined as "'.controller_a->config->{key_a}.'" and not "value_a" in config');
+
+ok( controller_b->config->{base_key} eq 'base_value', 'controller_b has expected config value for "base_key"') or
+ diag('"base_key" defined as "'.controller_b->config->{base_key}.'" and not "base_value" in config');
+
+ok( controller_b->config->{key_b} eq 'value_b', 'controller_b has expected config value for "key_b"') or
+ diag('"key_b" defined as "'.controller_b->config->{key_b}.'" and not "value_b" in config');
+
+# second round, does each controller have the expected number of config values? If this test fails there is
+# probably some data collision between the controllers.
+
+ok( scalar(keys %{base_controller->config}) == 1, 'base_controller has the expected number of config values') or
+ diag("base_controller should have 1 config value, but it has ".scalar(keys %{base_controller->config}));
+
+ok( scalar(keys %{controller_a->config}) == 2, 'controller_a has the expected number of config values') or
+ diag("controller_a should have 2 config value, but it has ".scalar(keys %{base_controller->config}));
+
+ok( scalar(keys %{controller_b->config}) == 2, 'controller_b has the expected number of config values') or
+ diag("controller_a should have 2 config value, but it has ".scalar(keys %{base_controller->config}));
Modified: trunk/Catalyst-Runtime/t/unit_core_merge_config_hashes.t
===================================================================
--- trunk/Catalyst-Runtime/t/unit_core_merge_config_hashes.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/unit_core_merge_config_hashes.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -2,42 +2,42 @@
use warnings;
use Test::More;
-
-my @tests = (
- {
- given => [ { a => 1 }, { b => 1 } ],
- expects => { a => 1, b => 1 }
- },
- {
- given => [ { a => 1 }, { a => { b => 1 } } ],
- expects => { a => { b => 1 } }
- },
- {
- given => [ { a => { b => 1 } }, { a => 1 } ],
- expects => { a => 1 }
- },
- {
- given => [ { a => 1 }, { a => [ 1 ] } ],
- expects => { a => [ 1 ] }
- },
- {
- given => [ { a => [ 1 ] }, { a => 1 } ],
- expects => { a => 1 }
- },
- {
- given => [ { a => { b => 1 } }, { a => { b => 2 } } ],
- expects => { a => { b => 2 } }
- },
- {
- given => [ { a => { b => 1 } }, { a => { c => 1 } } ],
- expects => { a => { b => 1, c => 1 } }
- },
-);
+my @tests = (
+ {
+ given => [ { a => 1 }, { b => 1 } ],
+ expects => { a => 1, b => 1 }
+ },
+ {
+ given => [ { a => 1 }, { a => { b => 1 } } ],
+ expects => { a => { b => 1 } }
+ },
+ {
+ given => [ { a => { b => 1 } }, { a => 1 } ],
+ expects => { a => 1 }
+ },
+ {
+ given => [ { a => 1 }, { a => [ 1 ] } ],
+ expects => { a => [ 1 ] }
+ },
+ {
+ given => [ { a => [ 1 ] }, { a => 1 } ],
+ expects => { a => 1 }
+ },
+ {
+ given => [ { a => { b => 1 } }, { a => { b => 2 } } ],
+ expects => { a => { b => 2 } }
+ },
+ {
+ given => [ { a => { b => 1 } }, { a => { c => 1 } } ],
+ expects => { a => { b => 1, c => 1 } }
+ },
+);
+
plan tests => scalar @tests + 1;
use_ok('Catalyst');
-for my $test ( @ tests ) {
- is_deeply( Catalyst->merge_config_hashes( @{ $test->{ given } } ), $test->{ expects } );
-}
+for my $test ( @ tests ) {
+ is_deeply( Catalyst->merge_config_hashes( @{ $test->{ given } } ), $test->{ expects } );
+}
Modified: trunk/Catalyst-Runtime/t/unit_core_mvc.t
===================================================================
--- trunk/Catalyst-Runtime/t/unit_core_mvc.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/unit_core_mvc.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -82,9 +82,9 @@
#checking @args passed to ACCEPT_CONTEXT
my $args;
{
- no warnings;
- *MyApp::Model::M::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
- *MyApp::View::V::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
+ no warnings;
+ *MyApp::Model::M::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
+ *MyApp::View::V::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
}
MyApp->model('M', qw/foo bar/);
is_deeply($args, [qw/foo bar/], '$c->model args passed to ACCEPT_CONTEXT ok');
Modified: trunk/Catalyst-Runtime/t/unit_core_path_to.t
===================================================================
--- trunk/Catalyst-Runtime/t/unit_core_path_to.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/unit_core_path_to.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -17,10 +17,10 @@
my $os = $non_unix{$^O} ? $^O : 'Unix';
if( $os ne 'Unix' ) {
- plan skip_all => 'tests require Unix';
+ plan skip_all => 'tests require Unix';
}
else {
- plan tests => 3;
+ plan tests => 3;
}
use_ok('Catalyst');
Modified: trunk/Catalyst-Runtime/t/unit_load_catalyst_test.t
===================================================================
--- trunk/Catalyst-Runtime/t/unit_load_catalyst_test.t 2007-07-19 12:28:13 UTC (rev 6581)
+++ trunk/Catalyst-Runtime/t/unit_load_catalyst_test.t 2007-07-19 12:47:48 UTC (rev 6582)
@@ -1,16 +1,16 @@
-#!perl
-
-use strict;
-use warnings;
-
-use Test::More;
-
-plan tests => 3;
-
-use_ok('Catalyst::Test');
-
-eval "get('http://localhost')";
-isnt( $@, "", "get returns an error message with no app specified");
-
-eval "request('http://localhost')";
-isnt( $@, "", "request returns an error message with no app specified");
+#!perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+plan tests => 3;
+
+use_ok('Catalyst::Test');
+
+eval "get('http://localhost')";
+isnt( $@, "", "get returns an error message with no app specified");
+
+eval "request('http://localhost')";
+isnt( $@, "", "request returns an error message with no app specified");
More information about the Catalyst-commits
mailing list