Skip to content

Commit

Permalink
Swapped out CGI::Cookie for CGI::Simple::Cookie, dumped Test::MockObj…
Browse files Browse the repository at this point in the history
…ect from the test suite

git-svn-id: http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst@4225 4ad37cd2-5fec-0310-835f-b3785c72a374
  • Loading branch information
matthewt committed May 26, 2006
1 parent b648549 commit 95367d9
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 29 deletions.
3 changes: 2 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down
11 changes: 6 additions & 5 deletions lib/Catalyst/Engine.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand All @@ -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},
Expand Down Expand Up @@ -363,15 +364,15 @@ sub prepare_connection { }

=head2 $self->prepare_cookies($c)
Parse cookies from header. Sets a L<CGI::Cookie> object.
Parse cookies from header. Sets a L<CGI::Simple::Cookie> object.
=cut

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) } );
}
}

Expand Down
7 changes: 4 additions & 3 deletions t/live_engine_request_cookies.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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' );

Expand Down
11 changes: 6 additions & 5 deletions t/unit_core_path_to.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use strict;
use warnings;

use Test::More;
use Test::MockObject;

my %non_unix = (
MacOS => 1,
Expand All @@ -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' );
25 changes: 12 additions & 13 deletions t/unit_core_uri_for.t
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -49,20 +50,18 @@ 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',
'URI for absolute path'
);

{
$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' );
Expand Down

0 comments on commit 95367d9

Please sign in to comment.