Checking in changes prior to tagging of version 0.13. Changelog diff is: v0.13
Tomas Doran [Wed, 19 Aug 2009 21:27:07 +0000 (21:27 +0000)]
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)

Changes
Makefile.PL
lib/Catalyst/Plugin/Session/State/Cookie.pm
t/basic.t
t/no_new_method.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index 43c3aaf..0e86672 100644 (file)
--- a/Changes
+++ b/Changes
@@ -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)
index 07d7795..beaba1a 100644 (file)
@@ -5,8 +5,10 @@ all_from 'lib/Catalyst/Plugin/Session/State/Cookie.pm';
 
 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;
index 9f31965..d71e059 100644 (file)
@@ -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;
index b9559a7..76f53fe 100644 (file)
--- a/t/basic.t
+++ b/t/basic.t
@@ -4,81 +4,86 @@ use strict;
 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 $cxt =
-  Test::MockObject::Extends->new("Catalyst::Plugin::Session::State::Cookie");
-
-$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 $cookies_called = 0;
+$res_meta->add_method( cookies => sub { $cookies_called++; \%res_cookies });
+my $res = $res_meta->name->new;
+
+my $cxt_meta = Class::MOP::Class->create_anon_class( superclasses => ["Catalyst::Plugin::Session::State::Cookie", 'Moose::Object'] );
+
+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" );
+
diff --git a/t/no_new_method.t b/t/no_new_method.t
new file mode 100644 (file)
index 0000000..a934eaa
--- /dev/null
@@ -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';
+