From: Matt S Trout Date: Fri, 26 May 2006 16:59:04 +0000 (+0000) Subject: Swapped out CGI::Cookie for CGI::Simple::Cookie, dumped Test::MockObject from the... X-Git-Tag: 5.7099_04~564 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=fa32ac82eacd5c38b4b4dda10c472901a59c72fe Swapped out CGI::Cookie for CGI::Simple::Cookie, dumped Test::MockObject from the test suite --- diff --git a/Changes b/Changes index f7c1a37..233fadb 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ This file documents the revision history for Perl extension Catalyst. - - Removed test dependency on Test::NoWarnings + - Swapped out CGI::Cookie in favour of CGI::Simple::Cookie + - Removed test dependencies on Test::NoWarnings, Test::MockObject - Removed dependency on UNIVERSAL::require - Split out Catalyst::Helper into a new distribution - un-bundled the plugins as they are now pre-reqs for Catalyst::Helper diff --git a/Makefile.PL b/Makefile.PL index 902af0d..93f7dcd 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -10,7 +10,7 @@ requires 'Carp'; requires 'Class::Accessor::Fast'; requires 'Class::Data::Inheritable'; requires 'Class::Inspector' => '1.06'; -requires 'CGI::Cookie'; +requires 'CGI::Simple::Cookie'; requires 'Data::Dump'; requires 'File::Modified'; requires 'HTML::Entities'; @@ -25,7 +25,6 @@ requires 'NEXT'; requires 'Path::Class' => '0.09'; requires 'Scalar::Util'; requires 'Text::SimpleTable' => '0.03'; -requires 'Test::MockObject'; requires 'Time::HiRes'; requires 'Tree::Simple' => '1.15'; requires 'Tree::Simple::Visitor::FindByPath'; diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 6e46c81..7f7a661 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -2,7 +2,7 @@ package Catalyst::Engine; use strict; use base 'Class::Accessor::Fast'; -use CGI::Cookie; +use CGI::Simple::Cookie; use Data::Dump qw/dump/; use HTML::Entities; use HTTP::Body; @@ -54,7 +54,8 @@ sub finalize_body { =head2 $self->finalize_cookies($c) -Create CGI::Cookies from $c->res->cookies, and set them as response headers. +Create CGI::Simple::Cookie objects from $c->res->cookies, and set them as +response headers. =cut @@ -67,7 +68,7 @@ sub finalize_cookies { my $val = $c->response->cookies->{$name}; - my $cookie = CGI::Cookie->new( + my $cookie = CGI::Simple::Cookie->new( -name => $name, -value => $val->{value}, -expires => $val->{expires}, @@ -363,7 +364,7 @@ sub prepare_connection { } =head2 $self->prepare_cookies($c) -Parse cookies from header. Sets a L object. +Parse cookies from header. Sets a L object. =cut @@ -371,7 +372,7 @@ sub prepare_cookies { my ( $self, $c ) = @_; if ( my $header = $c->request->header('Cookie') ) { - $c->req->cookies( { CGI::Cookie->parse($header) } ); + $c->req->cookies( { CGI::Simple::Cookie->parse($header) } ); } } diff --git a/t/live_engine_request_cookies.t b/t/live_engine_request_cookies.t index 5677b4e..4247ca4 100644 --- a/t/live_engine_request_cookies.t +++ b/t/live_engine_request_cookies.t @@ -10,7 +10,7 @@ use Test::More tests => 13; use Catalyst::Test 'TestApp'; use Catalyst::Request; -use CGI::Cookie; +use CGI::Simple::Cookie; use HTTP::Headers; use HTTP::Request::Common; use URI; @@ -28,10 +28,11 @@ use URI; 'Content is a serialized Catalyst::Request' ); ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' ); isa_ok( $creq, 'Catalyst::Request' ); - isa_ok( $creq->cookies->{Catalyst}, 'CGI::Cookie', 'Cookie Catalyst' ); + isa_ok( $creq->cookies->{Catalyst}, 'CGI::Simple::Cookie', + 'Cookie Catalyst' ); is( $creq->cookies->{Catalyst}->name, 'Catalyst', 'Cookie Catalyst name' ); is( $creq->cookies->{Catalyst}->value, 'Cool', 'Cookie Catalyst value' ); - isa_ok( $creq->cookies->{Cool}, 'CGI::Cookie', 'Cookie Cool' ); + isa_ok( $creq->cookies->{Cool}, 'CGI::Simple::Cookie', 'Cookie Cool' ); is( $creq->cookies->{Cool}->name, 'Cool', 'Cookie Cool name' ); is( $creq->cookies->{Cool}->value, 'Catalyst', 'Cookie Cool value' ); diff --git a/t/unit_core_path_to.t b/t/unit_core_path_to.t index c675739..52c11a3 100644 --- a/t/unit_core_path_to.t +++ b/t/unit_core_path_to.t @@ -2,7 +2,6 @@ use strict; use warnings; use Test::More; -use Test::MockObject; my %non_unix = ( MacOS => 1, @@ -24,15 +23,17 @@ else { plan tests => 3; } -my $context = Test::MockObject->new; - use_ok('Catalyst'); -$context->mock( 'config', sub { { home => '/home/sri/my-app/' } } ); +my $context = 'Catalyst'; + +my $config = Catalyst->config; + +$config->{home} = '/home/sri/my-app/'; is( Catalyst::path_to( $context, 'foo' ), '/home/sri/my-app/foo', 'Unix path' ); -$context->mock( 'config', sub { { home => '/Users/sri/myapp' } } ); +$config->{home} = '/Users/sri/myapp/'; is( Catalyst::path_to( $context, 'foo', 'bar' ), '/Users/sri/myapp/foo/bar', 'deep Unix path' ); diff --git a/t/unit_core_uri_for.t b/t/unit_core_uri_for.t index bd0690b..2fb1421 100644 --- a/t/unit_core_uri_for.t +++ b/t/unit_core_uri_for.t @@ -2,17 +2,18 @@ use strict; use warnings; use Test::More tests => 9; -use Test::MockObject; use URI; -my $request = Test::MockObject->new; -$request->mock( 'base', sub { URI->new('http://127.0.0.1/foo') } ); +use_ok('Catalyst'); -my $context = Test::MockObject->new; -$context->mock( 'request', sub { $request } ); -$context->mock( 'namespace', sub { 'yada' } ); +my $request = Catalyst::Request->new( { + base => URI->new('http://127.0.0.1/foo') + } ); -use_ok('Catalyst'); +my $context = Catalyst->new( { + request => $request, + namespace => 'yada', + } ); is( Catalyst::uri_for( $context, '/bar/baz' )->as_string, @@ -49,8 +50,8 @@ is( 'URI for undef action with query params in unicode' ); -$request->mock( 'base', sub { URI->new('http://localhost:3000/') } ); -$request->mock( 'match', sub { 'orderentry/contract' } ); +$request->base( URI->new('http://localhost:3000/') ); +$request->match( 'orderentry/contract' ); is( Catalyst::uri_for( $context, '/Orderentry/saveContract' )->as_string, 'http://localhost:3000/Orderentry/saveContract', @@ -58,11 +59,9 @@ is( ); { - $request->mock( 'base', sub { URI->new('http://127.0.0.1/') } ); + $request->base( URI->new('http://127.0.0.1/') ); - my $context = Test::MockObject->new; - $context->mock( 'request', sub { $request } ); - $context->mock( 'namespace', sub { '' } ); + $context->namespace(''); is( Catalyst::uri_for( $context, '/bar/baz' )->as_string, 'http://127.0.0.1/bar/baz', 'URI with no base or match' );