X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Funit_core_component_loading.t;h=d27b9b7078dd20b65d1514c520b38ac05782c809;hb=3932d8818a3c5112315a8757b6db7a3678755f7e;hp=bae3c5e6d1ade154983d23d9bbf3bbeb78ed2738;hpb=7fa2c9c1b85c98786655ad5169708d8dc84e8353;p=catagits%2FCatalyst-Runtime.git diff --git a/t/unit_core_component_loading.t b/t/unit_core_component_loading.t index bae3c5e..d27b9b7 100644 --- a/t/unit_core_component_loading.t +++ b/t/unit_core_component_loading.t @@ -9,6 +9,8 @@ use warnings; use File::Spec; use File::Path; +use Test::MockObject; + my $libdir = 'test_trash'; unshift(@INC, $libdir); @@ -40,7 +42,7 @@ my @components = ( { type => 'View', prefix => 'View', name => 'Foo' }, ); -sub write_component_file { +sub write_component_file { my ($dir_list, $module_name, $content) = @_; my $dir = File::Spec->catdir(@$dir_list); @@ -63,10 +65,10 @@ sub make_component_file { write_component_file(\@dir_list, $name_final, <NEXT::COMPONENT(\@_); + my \$self = shift->next::method(\@_); no strict 'refs'; *{\__PACKAGE__ . "::whoami"} = sub { return \__PACKAGE__; }; \$self; @@ -82,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'); @@ -141,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,8 +180,8 @@ write_component_file([$libdir, $appclass, 'Model'], 'TopLevel', <NEXT::COMPONENT(\@_); + + my \$self = shift->next::method(\@_); no strict 'refs'; *{\__PACKAGE__ . "::whoami"} = sub { return \__PACKAGE__; }; \$self; @@ -185,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