);
}
our $warnings = 0;
-our $loaded = 0;
Moose::Meta::Class->create('Some::Test::Object');
);
};
local *Catalyst::Log::warn = sub { $warnings++ };
- *Class::MOP::load_class = sub {
- my $class = shift;
- $loaded++
- if Class::MOP::is_class_loaded($class) && $class =~ /^MyMVCTestApp/
- };
__PACKAGE__->setup;
}
ok( $warnings, 'Issues deprecated warnings' );
-is( $loaded, scalar @complist + 1, 'Loaded all components' );
+is( @{[ MyMVCTestApp->component_list ]}, scalar @complist + 1, 'Loaded all components' );
+
+{
+ package MyStringThing;
+
+ use overload '""' => sub { $_[0]->{string} }, fallback => 1;
+}
is( MyMVCTestApp->view('View'), 'MyMVCTestApp::V::View', 'V::View ok' );
);
};
local *Catalyst::Log::warn = sub { $warnings++ };
- *Class::MOP::load_class = sub {
- my $class = shift;
- $loaded++
- if Class::MOP::is_class_loaded($class) && $class =~ /^MyMVCTestAppDefaultView/
- };
__PACKAGE__->config( default_view => 'V' );
);
};
local *Catalyst::Log::warn = sub { $warnings++ };
- *Class::MOP::load_class = sub {
- my $class = shift;
- $loaded++
- if Class::MOP::is_class_loaded($class) && $class =~ /^MyMVCTestAppDefaultModel/
- };
__PACKAGE__->config( default_model => 'M' );
# object w/ qr{}
is_deeply( [ MyMVCTestApp->model( qr{Test} ) ], [ MyMVCTestApp->components->{'MyMVCTestApp::Model::Test::Object'} ], 'Object returned' );
+ is_deeply([ MyMVCTestApp->model( bless({ string => 'Model' }, 'MyStringThing') ) ], [ MyMVCTestApp->components->{'MyMVCTestApp::M::Model'} ], 'Explicit model search with overloaded object');
+
+ {
+ my $warnings = 0;
+ no warnings 'redefine';
+ local *Catalyst::Log::warn = sub { $warnings++ };
+
+ # object w/ regexp fallback
+ is_deeply( [ MyMVCTestApp->model( bless({ string => 'Test' }, 'MyStringThing') ) ], [ MyMVCTestApp->components->{'MyMVCTestApp::Model::Test::Object'} ], 'Object returned' );
+ ok( $warnings, 'regexp fallback warnings' );
+ }
+
{
my $warnings = 0;
no warnings 'redefine';
no warnings 'redefine';
- *Class::MOP::load_class = sub {
- $loaded++;
- };
-
__PACKAGE__->config( { disable_component_resolution_regex_fallback => 1 } );
__PACKAGE__->components( { map { ( ref($_)||$_ , $_ ) }