[Catalyst-commits] r11176 - in
trunk/Catalyst-Plugin-Session-State-Cookie: .
lib/Catalyst/Plugin/Session/State t
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Wed Aug 19 21:27:08 GMT 2009
Author: t0m
Date: 2009-08-19 21:27:07 +0000 (Wed, 19 Aug 2009)
New Revision: 11176
Added:
trunk/Catalyst-Plugin-Session-State-Cookie/t/no_new_method.t
Modified:
trunk/Catalyst-Plugin-Session-State-Cookie/Changes
trunk/Catalyst-Plugin-Session-State-Cookie/Makefile.PL
trunk/Catalyst-Plugin-Session-State-Cookie/lib/Catalyst/Plugin/Session/State/Cookie.pm
trunk/Catalyst-Plugin-Session-State-Cookie/t/basic.t
Log:
Checking in changes prior to tagging of version 0.13. Changelog diff is:
Index: Changes
===================================================================
--- Changes (revision 10953)
+++ Changes (working copy)
@@ -1,5 +1,14 @@
Revision history for Perl extension Catalyst::Plugin::Session::State::Cookie
+0.13 2009-08-19
+ - Remove Test::MockObject from the test suite as prone to failing on
+ some platforms and perl versions due to its UNIVERSAL:: package
+ dependencies.
+ - Remove Class::Accessor::Fast and replace with Moose. This allows
+ us to not have a ->new method, This is more correct for Plugins
+ and also means that Catalyst is not forced to invoke the scary
+ replace_constructor at scope end handling.
+
0.12 2009-07-18
- Introduced a new option cookie_httponly
- Option cookie_secure extended (old syntax fully supported)
Modified: trunk/Catalyst-Plugin-Session-State-Cookie/Changes
===================================================================
--- trunk/Catalyst-Plugin-Session-State-Cookie/Changes 2009-08-19 21:20:04 UTC (rev 11175)
+++ trunk/Catalyst-Plugin-Session-State-Cookie/Changes 2009-08-19 21:27:07 UTC (rev 11176)
@@ -1,5 +1,14 @@
Revision history for Perl extension Catalyst::Plugin::Session::State::Cookie
+0.13 2009-08-19
+ - Remove Test::MockObject from the test suite as prone to failing on
+ some platforms and perl versions due to its UNIVERSAL:: package
+ dependencies.
+ - Remove Class::Accessor::Fast and replace with Moose. This allows
+ us to not have a ->new method, This is more correct for Plugins
+ and also means that Catalyst is not forced to invoke the scary
+ replace_constructor at scope end handling.
+
0.12 2009-07-18
- Introduced a new option cookie_httponly
- Option cookie_secure extended (old syntax fully supported)
Modified: trunk/Catalyst-Plugin-Session-State-Cookie/Makefile.PL
===================================================================
--- trunk/Catalyst-Plugin-Session-State-Cookie/Makefile.PL 2009-08-19 21:20:04 UTC (rev 11175)
+++ trunk/Catalyst-Plugin-Session-State-Cookie/Makefile.PL 2009-08-19 21:27:07 UTC (rev 11176)
@@ -5,8 +5,10 @@
requires 'Catalyst' => '5.80005';
requires 'Catalyst::Plugin::Session' => '0.19';
-requires 'Test::MockObject' => '1.01';
requires 'MRO::Compat';
+requires 'Moose';
+requires 'namespace::autoclean';
+test_requires 'Moose';
test_requires 'Test::More';
auto_install;
Modified: trunk/Catalyst-Plugin-Session-State-Cookie/lib/Catalyst/Plugin/Session/State/Cookie.pm
===================================================================
--- trunk/Catalyst-Plugin-Session-State-Cookie/lib/Catalyst/Plugin/Session/State/Cookie.pm 2009-08-19 21:20:04 UTC (rev 11175)
+++ trunk/Catalyst-Plugin-Session-State-Cookie/lib/Catalyst/Plugin/Session/State/Cookie.pm 2009-08-19 21:27:07 UTC (rev 11176)
@@ -1,15 +1,15 @@
package Catalyst::Plugin::Session::State::Cookie;
-use base qw/Catalyst::Plugin::Session::State Class::Accessor::Fast/;
+use Moose;
+use namespace::autoclean;
-use strict;
-use warnings;
+extends 'Catalyst::Plugin::Session::State';
use MRO::Compat;
use Catalyst::Utils ();
-our $VERSION = "0.12";
+our $VERSION = "0.13";
-BEGIN { __PACKAGE__->mk_accessors(qw/_deleted_session_id/) }
+has _deleted_session_id => ( is => 'rw' );
sub setup_session {
my $c = shift;
Modified: trunk/Catalyst-Plugin-Session-State-Cookie/t/basic.t
===================================================================
--- trunk/Catalyst-Plugin-Session-State-Cookie/t/basic.t 2009-08-19 21:20:04 UTC (rev 11175)
+++ trunk/Catalyst-Plugin-Session-State-Cookie/t/basic.t 2009-08-19 21:27:07 UTC (rev 11176)
@@ -4,81 +4,86 @@
use warnings;
use Test::More tests => 13;
-use Test::MockObject;
-use Test::MockObject::Extends;
my $m;
BEGIN { use_ok( $m = "Catalyst::Plugin::Session::State::Cookie" ) }
-my $cookie = Test::MockObject->new;
-$cookie->set_always( value => "the session id" );
+my $cookie_meta = Class::MOP::Class->create_anon_class( superclasses => ['Moose::Object'] );
+my $cookie = $cookie_meta->name->new;
+$cookie_meta->add_method( value => sub { "the session id" } );
-my $req = Test::MockObject->new;
+my $req_meta = Class::MOP::Class->create_anon_class( superclasses => ['Moose::Object'] );
my %req_cookies;
-$req->set_always( cookies => \%req_cookies );
+$req_meta->add_method( cookies => sub { \%req_cookies } );
+my $req = $req_meta->name->new;
-my $res = Test::MockObject->new;
+my $res_meta = Class::MOP::Class->create_anon_class( superclasses => ['Moose::Object'] );
my %res_cookies;
-$res->set_always( cookies => \%res_cookies );
+my $cookies_called = 0;
+$res_meta->add_method( cookies => sub { $cookies_called++; \%res_cookies });
+my $res = $res_meta->name->new;
-my $cxt =
- Test::MockObject::Extends->new("Catalyst::Plugin::Session::State::Cookie");
+my $cxt_meta = Class::MOP::Class->create_anon_class( superclasses => ["Catalyst::Plugin::Session::State::Cookie", 'Moose::Object'] );
-$cxt->set_always( config => {} );
-$cxt->set_always( request => $req );
-$cxt->set_always( response => $res );
-$cxt->set_always( session => { } );
-$cxt->set_always( session_expires => 123 );
-$cxt->set_false("debug");
+my $config = {};
+$cxt_meta->add_method( config => sub { $config });
+$cxt_meta->add_method( request => sub { $req });
+$cxt_meta->add_method( response => sub { $res });
+$cxt_meta->add_method( session => sub { { } } );
+$cxt_meta->add_method( session_expires => sub { 123 });
+$cxt_meta->add_method("debug" => sub { 0 });
my $sessionid;
-$cxt->mock( sessionid => sub { shift; $sessionid = shift if @_; $sessionid } );
+$cxt_meta->add_method( sessionid => sub { shift; $sessionid = shift if @_; $sessionid } );
can_ok( $m, "setup_session" );
+my $cxt = $cxt_meta->name->new;
$cxt->setup_session;
-like( $cxt->config->{session}{cookie_name},
+like( $config->{session}{cookie_name},
qr/_session$/, "default cookie name is set" );
-$cxt->config->{session}{cookie_name} = "session";
+$config->{session}{cookie_name} = "session";
can_ok( $m, "get_session_id" );
ok( !$cxt->get_session_id, "no session id yet");
-$cxt->clear;
+$cxt = $cxt_meta->name->new;
%req_cookies = ( session => $cookie );
is( $cxt->get_session_id, "the session id", "session ID was restored from cookie" );
-$cxt->clear;
-$res->clear;
+$cxt_meta->name->new;
+%res_cookies = ();
can_ok( $m, "set_session_id" );
$cxt->set_session_id("moose");
-$res->called_ok( "cookies", "created a cookie on set" );
+ok( $cookies_called, "created a cookie on set" );
+$cookies_called = 0;
-$cxt->clear;
-$res->clear;
+$cxt_meta->name->new;
+%res_cookies = ();
$cxt->set_session_id($sessionid);
-$res->called_ok( "cookies", "response cookie was set when sessionid changed" );
+ok( $cookies_called, "response cookie was set when sessionid changed" );
is_deeply(
\%res_cookies,
{ session => { value => $sessionid, httponly => 1, expires => 123 } },
"cookie was set correctly"
);
-$cxt->clear;
-$req->clear;
+$cxt_meta->name->new;
can_ok( $m, "cookie_is_rejecting" );
%req_cookies = ( path => '/foo' );
-$req->set_always( path => '' );
+my $path = '';
+$req_meta->add_method( path => sub { $path } );
ok( $cxt->cookie_is_rejecting(\%req_cookies), "cookie is rejecting" );
-$req->set_always( path => 'foo/bar' );
+$path = 'foo/bar';
ok( !$cxt->cookie_is_rejecting(\%req_cookies), "cookie is not rejecting" );
+
Added: trunk/Catalyst-Plugin-Session-State-Cookie/t/no_new_method.t
===================================================================
--- trunk/Catalyst-Plugin-Session-State-Cookie/t/no_new_method.t (rev 0)
+++ trunk/Catalyst-Plugin-Session-State-Cookie/t/no_new_method.t 2009-08-19 21:27:07 UTC (rev 11176)
@@ -0,0 +1,7 @@
+use strict;
+use warnings;
+use Test::More tests => 1;
+use Catalyst::Plugin::Session::State::Cookie;
+
+ok !Catalyst::Plugin::Session::State::Cookie->can('new'), 'No new method';
+
More information about the Catalyst-commits
mailing list