use strict;
use warnings;
-use Moose::Meta::Class;
+{
+ no warnings 'redefine';
+ *Catalyst::Utils::ensure_class_loaded = sub { };
+}
-use_ok('Catalyst');
+use Moose::Meta::Class;
our @complist_suffix = qw/C::Controller M::Model V::View Controller::C Model::M View::V Controller::Model::Dummy::Model Model::Dummy::Model/;
use base qw/Catalyst/;
- sub locate_components {
- return (@::complist, 'MyMVCTestApp::Model::Test::Object');
- }
-
no warnings 'redefine';
- *Catalyst::Log::warn = sub { $::warnings++ };
- *Catalyst::Utils::ensure_class_loaded = sub {
+
+ local *Catalyst::IOC::Container::build_locate_components_service = sub {
+ my $self = shift;
+
+ return Bread::Board::BlockInjection->new(
+ lifecycle => 'Singleton',
+ name => 'locate_components',
+ block => sub {
+ return [@complist, 'MyMVCTestApp::Model::Test::Object'];
+
+ },
+ );
+ };
+ local *Catalyst::Log::warn = sub { $warnings++ };
+ *Class::MOP::load_class = sub {
my $class = shift;
- $::loaded++
+ $loaded++
if Class::MOP::is_class_loaded($class) && $class =~ /^MyMVCTestApp/
};
'models ok');
{
- $warnings = 0;
+ my $warnings = 0;
+ no warnings 'redefine';
+ local *Catalyst::Log::warn = sub { $warnings++ };
is( MyMVCTestApp->view , undef, 'view() w/o a default is undef' );
ok( $warnings, 'warnings thrown for view() w/o a default' );
'current_view_instance precedes current_view ok');
{
- $warnings = 0;
+ my $warnings = 0;
+ no warnings 'redefine';
+ local *Catalyst::Log::warn = sub { $warnings++ };
is( MyMVCTestApp->model, undef, 'model() w/o a default is undef' );
ok( $warnings, 'warnings thrown for model() w/o a default' );
package MyMVCTestAppDefaultView;
use base qw/Catalyst/;
+ no warnings 'redefine';
- sub locate_components {
- return @::complist_default_view;
- }
+ local *Catalyst::IOC::Container::build_locate_components_service = sub {
+ my $self = shift;
- no warnings 'redefine';
- *Catalyst::Utils::ensure_class_loaded = sub {
+ return Bread::Board::BlockInjection->new(
+ lifecycle => 'Singleton',
+ name => 'locate_components',
+ block => sub {
+ return \@complist_default_view;
+ },
+ );
+ };
+ local *Catalyst::Log::warn = sub { $warnings++ };
+ *Class::MOP::load_class = sub {
my $class = shift;
- $::loaded++
+ $loaded++
if Class::MOP::is_class_loaded($class) && $class =~ /^MyMVCTestAppDefaultView/
};
use base qw/Catalyst/;
- sub locate_components {
- return @::complist_default_model;
- }
-
no warnings 'redefine';
- *Catalyst::Utils::ensure_class_loaded = sub {
+
+ local *Catalyst::IOC::Container::build_locate_components_service = sub {
+ my $self = shift;
+
+ return Bread::Board::BlockInjection->new(
+ lifecycle => 'Singleton',
+ name => 'locate_components',
+ block => sub {
+ return \@complist_default_model;
+ },
+ );
+ };
+ local *Catalyst::Log::warn = sub { $warnings++ };
+ *Class::MOP::load_class = sub {
my $class = shift;
- $::loaded++
+ $loaded++
if Class::MOP::is_class_loaded($class) && $class =~ /^MyMVCTestAppDefaultModel/
};
is_deeply( [ MyMVCTestApp->model( qr{Test} ) ], [ MyMVCTestApp->components->{'MyMVCTestApp::Model::Test::Object'} ], 'Object returned' );
{
- $warnings = 0;
+ my $warnings = 0;
+ no warnings 'redefine';
+ local *Catalyst::Log::warn = sub { $warnings++ };
# object w/ regexp fallback
is( MyMVCTestApp->model( 'Test' ), undef, 'no regexp fallback' );
use base qw/Catalyst/;
+ no warnings 'redefine';
+
+ *Class::MOP::load_class = sub {
+ $loaded++;
+ };
+
__PACKAGE__->config( { disable_component_resolution_regex_fallback => 1 } );
__PACKAGE__->components( { map { ( ref($_)||$_ , $_ ) }