Merge 'trunk' into 'index_default_fuckage'
Rafael Kitover [Sun, 21 Jun 2009 00:19:34 +0000 (00:19 +0000)]
r5579@hlagh (orig r10594):  t0m | 2009-06-19 13:35:41 -0700
Just initialize a logger which only logs fatal errors, no mock needed
r5580@hlagh (orig r10595):  t0m | 2009-06-19 13:39:19 -0700
Remove Test::MockObject
r5581@hlagh (orig r10596):  t0m | 2009-06-19 13:39:58 -0700
Remove Test::MockObject
r5582@hlagh (orig r10597):  t0m | 2009-06-19 13:41:46 -0700
Remove MockObject
r5583@hlagh (orig r10598):  t0m | 2009-06-19 13:44:15 -0700
1 more MockObject removal
r5584@hlagh (orig r10599):  t0m | 2009-06-19 13:46:45 -0700
Remove MockObject from Makefile.PL
r5596@hlagh (orig r10605):  t0m | 2009-06-20 16:23:19 -0700
Re-add lukes specific regression test from r10498
r5597@hlagh (orig r10606):  t0m | 2009-06-20 16:25:31 -0700
Update test to be TODO, and note this case used to fail on 5.7

Changes
Makefile.PL
t/deprecated.t
t/unit_core_component_loading.t
t/unit_core_plugin.t
t/unit_core_setup.t
t/unit_core_setup_stats.t
t/unit_core_uri_for.t

diff --git a/Changes b/Changes
index ed00869..5a5f47d 100644 (file)
--- a/Changes
+++ b/Changes
@@ -4,6 +4,8 @@
         -  Revert change to URL encode things passed into $c->uri_for
            Args and CaptureArgs as this causes breakage to pre-existing
            applications.
+        -  Remove use of Test::MockObject as it doesn't install from CPAN
+           in some environments.
 
 5.80005 2009-06-06 14:40:00
 
index af34df9..a1b635a 100644 (file)
@@ -38,9 +38,6 @@ requires 'MRO::Compat';
 recommends 'B::Hooks::OP::Check::StashChange';
 
 test_requires 'Class::Data::Inheritable';
-test_requires 'Test::MockObject' => '1.07'; # Newish (hah, 2006!) version to
-                                            # hopefully avoid broken distro
-                                            # packages (RT#46104)
 test_requires 'Test::Exception';
 
 # aggregate tests if AGGREGATE_TESTS is set and a recent Test::Aggregate is available
index a7e2997..cfb5adf 100644 (file)
@@ -5,7 +5,6 @@ use warnings;
 use FindBin qw/$Bin/;
 use lib "$Bin/lib";
 use Test::More tests => 4;
-use Test::MockObject;
 
 my $warnings;
 BEGIN { # Do this at compile time in case we generate a warning when use
@@ -15,8 +14,17 @@ BEGIN { # Do this at compile time in case we generate a warning when use
 use Catalyst; # Cause catalyst to be used so I can fiddle with the logging.
 my $mvc_warnings;
 BEGIN {
-    my $logger = Test::MockObject->new;
-    $logger->mock('warn', sub { $mvc_warnings++ if $_[1] =~ /switch your class names/ });
+    my $logger = Class::MOP::Class->create_anon_class(
+    methods => {
+        warn => sub {
+            if ($_[1] =~ /switch your class names/) {
+               $mvc_warnings++;
+                return;
+            }
+            die "Caught unexpected warning: " . $_[1];
+        },
+    },
+)->new_object;
     Catalyst->log($logger);
 }
 
index d27b9b7..c8098c6 100644 (file)
@@ -9,8 +9,6 @@ use warnings;
 use File::Spec;
 use File::Path;
 
-use Test::MockObject;
-
 my $libdir = 'test_trash';
 unshift(@INC, $libdir);
 
@@ -85,15 +83,7 @@ foreach my $component (@components) {
 }
 
 my $shut_up_deprecated_warnings = q{
-    use Test::MockObject;
-    my $old_logger = __PACKAGE__->log;
-    my $logger = Test::MockObject->new;
-    $logger->mock('warn', sub { 
-        my $self = shift;
-        return if $_[0] =~ /deprecated/;
-        $old_logger->warn(@_);
-    });
-    __PACKAGE__->log($logger);
+    __PACKAGE__->log(Catalyst::Log->new('fatal'));
 };
 
 eval "package $appclass; use Catalyst; $shut_up_deprecated_warnings __PACKAGE__->setup";
index cb48159..93d08d8 100644 (file)
@@ -2,7 +2,6 @@
 
 use strict;
 use warnings;
-use Test::MockObject::Extends;
 
 use Test::More tests => 24;
 
@@ -20,15 +19,18 @@ use lib 't/lib';
 my $warnings = 0;
 
 use PluginTestApp;
-my $logger = Test::MockObject::Extends->new(PluginTestApp->log);
-$logger->mock('warn', sub {
-    if ($_[1] =~ /plugin method is deprecated/) {
-        $warnings++;
-        return;
-    }
-    die "Caught unexpected warning: " . $_[1];
-});
-#PluginTestApp->log($logger);
+my $logger = Class::MOP::Class->create_anon_class(
+    methods => {
+        warn => sub {
+            if ($_[1] =~ /plugin method is deprecated/) {
+               $warnings++;
+                return;
+            }
+            die "Caught unexpected warning: " . $_[1];
+        },
+    },
+)->new_object;
+PluginTestApp->log($logger);
 
 use Catalyst::Test qw/PluginTestApp/;
 
index 1e6e572..00ee842 100644 (file)
@@ -1,5 +1,6 @@
 use strict;
 use warnings;
+use Class::MOP::Class;
 use Catalyst::Runtime;
 
 use Test::More tests => 29;
@@ -67,13 +68,13 @@ local %ENV; # Don't allow env variables to mess us up.
     ok $log->is_debug, 'Debugging should be enabled';
     ok !$c->debug, 'Catalyst debugging turned off';
 }
+my $log_meta = Class::MOP::Class->create_anon_class(
+    methods => { map { $_ => sub { 0 } } qw/debug error fatal info warn/ },
+);
 {
     package MyTestAppWithOwnLogger;
     use base qw/Catalyst/;
-    use Test::MockObject;
-    my $log = Test::MockObject->new;
-    $log->set_false(qw/debug error fatal info warn/);
-    __PACKAGE__->log($log);
+    __PACKAGE__->log($log_meta->new_object);
     __PACKAGE__->setup('-Debug');
 }
 
index 9323e45..8cc979f 100644 (file)
@@ -2,18 +2,22 @@ use strict;
 use warnings;
 
 use Test::More tests => 5;
-use Test::MockObject;
+use Class::MOP::Class;
 
 use Catalyst ();
 
 my %log_messages; # TODO - Test log messages as expected.
-my $mock_log = Test::MockObject->new;
-foreach my $level (qw/debug info warn error fatal/) {
-    $mock_log->mock($level, sub { 
-        $log_messages{$level} ||= [];
-        push(@{ $log_messages{$level} }, $_[1]);
-    });
-}
+my $mock_log = Class::MOP::Class->create_anon_class(
+    methods => {
+        map { my $level = $_;
+            $level => sub {
+                $log_messages{$level} ||= [];
+                push(@{ $log_messages{$level} }, $_[1]);
+            },
+        }
+        qw/debug info warn error fatal/,
+    },
+)->new_object;
 
 sub mock_app {
     my $name = shift;
index 4018b03..af47c9f 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 18;
+use Test::More tests => 19;
 use URI;
 
 use_ok('Catalyst');
@@ -51,6 +51,11 @@ is( Catalyst::uri_for( $context, qw/bar wibble?/, 'with space' )->as_string,
     'http://127.0.0.1/foo/yada/bar/wibble%3F/with%20space', 'Space gets encoded'
 );
 
+is(
+    Catalyst::uri_for( $context, '/bar', 'with+plus', { 'also' => 'with+plus' })->as_string,
+    'http://127.0.0.1/foo/bar/with+plus?also=with%2Bplus',
+    'Plus is not encoded'
+);
 
 # test with utf-8
 is(
@@ -118,12 +123,13 @@ TODO: {
         'http://127.0.0.1/%21/%2A/%27/%2B/%29/%3B/%3A/%40/%26/%3D/%24/%2C/%2F/%3F/%25/%23/%5B/%5D',
         'rfc 3986 reserved characters'
     );
-}
 
-# jshirley bug t0m fucked in r10097
-is(
-    Catalyst::uri_for( $context, qw|{1} {2}| )->as_string,
-    'http://127.0.0.1/{1}/{2}',
-    'not-escaping unreserved characters'
-);
+    # jshirley bug - why the hell does only one of these get encoded
+    #                has been like this forever however.
+    is(
+        Catalyst::uri_for( $context, qw|{1} {2}| )->as_string,
+        'http://127.0.0.1/{1}/{2}',
+        'not-escaping unreserved characters'
+    );
+}