X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Faggregate%2Funit_core_mvc.t;h=c84e1d460c995051a882e37208708538ec46e4a7;hp=b04c3a3dd2acb3b0794d67f45289495b42a78c33;hb=4995a5cebbc06c813c20daabc8d248247f33cb37;hpb=bf590d36b554c02f9af89d8f5677be23297fbaf3 diff --git a/t/aggregate/unit_core_mvc.t b/t/aggregate/unit_core_mvc.t index b04c3a3..c84e1d4 100644 --- a/t/aggregate/unit_core_mvc.t +++ b/t/aggregate/unit_core_mvc.t @@ -1,4 +1,4 @@ -use Test::More tests => 51; +use Test::More; use strict; use warnings; @@ -24,6 +24,12 @@ my @complist = __PACKAGE__->setup_log; } +{ + package MyStringThing; + + use overload '""' => sub { $_[0]->{string} }, fallback => 1; +} + is( MyMVCTestApp->view('View'), 'MyMVCTestApp::V::View', 'V::View ok' ); is( MyMVCTestApp->controller('Controller'), @@ -117,6 +123,18 @@ is ( MyMVCTestApp->model , 'MyMVCTestApp::Model::M', 'default_model in class met # 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'; @@ -225,3 +243,5 @@ is ( MyMVCTestApp->model , 'MyMVCTestApp::Model::M', 'default_model in class met is( MyApp::WithoutRegexFallback->controller('Foo'), undef, 'no controller Foo found'); ok( !$warnings, 'no regexp fallback warnings' ); } + +done_testing;