From: André Walker Date: Tue, 14 Jun 2011 14:05:34 +0000 (-0300) Subject: test cleaned up using Moose::Meta::Class X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=495c46deee8476c964f132bfc1cc4d0e6c4bd459 test cleaned up using Moose::Meta::Class --- diff --git a/t/aggregate/unit_core_component_setup.t b/t/aggregate/unit_core_component_setup.t index e496a76..5586b42 100644 --- a/t/aggregate/unit_core_component_setup.t +++ b/t/aggregate/unit_core_component_setup.t @@ -1,71 +1,36 @@ -package TestAppComponents; -use warnings; use strict; -use base 'Catalyst'; +use warnings; +use Test::More; +use Moose::Meta::Class; -sub locate_components { - my @comps; - push @comps, "TestAppComponents::$_" for qw/ - C::Bar - C::Foo::Bar - C::Foo::Foo::Bar - C::Foo::Foo::Foo::Bar - Controller::Bar::Bar::Bar::Foo - Controller::Bar::Bar::Foo - Controller::Bar::Foo - Controller::Foo - M::Bar - M::Foo::Bar - M::Foo::Foo::Bar - M::Foo::Foo::Foo::Bar - Model::Bar::Bar::Bar::Foo - Model::Bar::Bar::Foo - Model::Bar::Foo - Model::Foo - V::Bar - V::Foo::Bar - V::Foo::Foo::Bar - V::Foo::Foo::Foo::Bar - View::Bar::Bar::Bar::Foo - View::Bar::Bar::Foo - View::Bar::Foo - View::Foo - /; - return @comps; -} +Moose::Meta::Class->create( TestAppComponents => ( + superclasses => ['Catalyst'], + methods => { + locate_components => \&overriden_locate_components, + }, +)); -__PACKAGE__->components( {} ); +TestAppComponents->components( {} ); -# this is so $c->container will work -__PACKAGE__->setup_config; +# this is so TestAppComponents->container will work +TestAppComponents->setup_config; -# this is so $c->log->warn will work -__PACKAGE__->setup_log; +# this is so TestAppComponents->log->warn will work +TestAppComponents->setup_log; -for my $component (TestAppComponents->locate_components) { - eval <locate_components; -1; -COMPONENT +for my $component (@comps) { + Moose::Meta::Class->create( $component => ( + superclasses => ['Catalyst::Component'], + )); } -package main; -use strict; -use warnings; - -use Test::More; - -my @comps = TestAppComponents->locate_components; - { my @loaded_comps; my $warnings = 0; - no warnings 'redefine'; + no warnings 'redefine', 'once'; local *Catalyst::Log::warn = sub { $warnings++ }; local *Catalyst::Utils::ensure_class_loaded = sub { my $class = shift; push @loaded_comps, $class; }; @@ -125,3 +90,34 @@ is_deeply( ); done_testing(); + +sub overriden_locate_components { + my @comps; + push @comps, "TestAppComponents::$_" for qw/ + C::Bar + C::Foo::Bar + C::Foo::Foo::Bar + C::Foo::Foo::Foo::Bar + Controller::Bar::Bar::Bar::Foo + Controller::Bar::Bar::Foo + Controller::Bar::Foo + Controller::Foo + M::Bar + M::Foo::Bar + M::Foo::Foo::Bar + M::Foo::Foo::Foo::Bar + Model::Bar::Bar::Bar::Foo + Model::Bar::Bar::Foo + Model::Bar::Foo + Model::Foo + V::Bar + V::Foo::Bar + V::Foo::Foo::Bar + V::Foo::Foo::Foo::Bar + View::Bar::Bar::Bar::Foo + View::Bar::Bar::Foo + View::Bar::Foo + View::Foo + /; + return @comps; +}