include test for failure mode
[catagits/Catalyst-Runtime.git] / t / unit_core_component_loading.t
index 5b6a4a7..d27b9b7 100644 (file)
@@ -9,6 +9,8 @@ use warnings;
 use File::Spec;
 use File::Path;
 
+use Test::MockObject;
+
 my $libdir = 'test_trash';
 unshift(@INC, $libdir);
 
@@ -63,9 +65,10 @@ sub make_component_file {
 
     write_component_file(\@dir_list, $name_final, <<EOF);
 package $fullname;
+use MRO::Compat;
 use base '$compbase';
 sub COMPONENT {
-    my \$self = shift->NEXT::COMPONENT(\@_);
+    my \$self = shift->next::method(\@_);
     no strict 'refs';
     *{\__PACKAGE__ . "::whoami"} = sub { return \__PACKAGE__; };
     \$self;
@@ -81,7 +84,19 @@ foreach my $component (@components) {
                         $component->{name});
 }
 
-eval "package $appclass; use Catalyst; __PACKAGE__->setup";
+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);
+};
+
+eval "package $appclass; use Catalyst; $shut_up_deprecated_warnings __PACKAGE__->setup";
 
 can_ok( $appclass, 'components');
 
@@ -140,6 +155,7 @@ foreach my $component (@components) {
 eval qq(
 package $appclass;
 use Catalyst;
+$shut_up_deprecated_warnings
 __PACKAGE__->config->{ setup_components } = {
     search_extra => [ '::Extra' ],
     except       => [ "${appclass}::Controller::Foo" ]
@@ -165,7 +181,7 @@ package ${appclass}::Model::TopLevel;
 use base 'Catalyst::Model';
 sub COMPONENT {
  
-    my \$self = shift->NEXT::COMPONENT(\@_);
+    my \$self = shift->next::method(\@_);
     no strict 'refs';
     *{\__PACKAGE__ . "::whoami"} = sub { return \__PACKAGE__; };
     \$self;
@@ -184,7 +200,7 @@ package ${appclass}::Model::TopLevel::Nested;
 use base 'Catalyst::Model';
 
 no warnings 'redefine';
-sub COMPONENT { return shift->NEXT::COMPONENT(\@_); }
+sub COMPONENT { return shift->next::method(\@_); }
 1;
 
 EOF