-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 <<COMPONENT;
-package $component;
-use warnings;
-use strict;
-use base 'Catalyst::Component';
+my @comps = TestAppComponents->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; };
);
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;
+}