X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Funit_core_mvc.t;h=8cb1fcb3a3d64edcebde54505c132979dc468701;hb=c23b894b1e0dda68841e82cfd85219d2627e7ac2;hp=6d1c7fcc9a46a025c970ffa5d0e4ab4d60a399b9;hpb=3fc0073c71b2590168ab0503100b475cb201a524;p=catagits%2FCatalyst-Runtime.git diff --git a/t/unit_core_mvc.t b/t/unit_core_mvc.t index 6d1c7fc..8cb1fcb 100644 --- a/t/unit_core_mvc.t +++ b/t/unit_core_mvc.t @@ -8,9 +8,6 @@ my @complist = map { "MyApp::$_"; } qw/C::Controller M::Model V::View Controller::C Model::M View::V Controller::Model::Dummy::Model Model::Dummy::Model/; -my $thingie={}; -bless $thingie,'MyApp::Model::Test::Object'; -push @complist,$thingie; { package MyApp; @@ -19,6 +16,10 @@ push @complist,$thingie; __PACKAGE__->components( { map { ( ref($_)||$_ , $_ ) } @complist } ); + my $thingie={}; + bless $thingie, 'Some::Test::Object'; + __PACKAGE__->components->{'MyApp::Model::Test::Object'} = $thingie; + # allow $c->log->warn to work __PACKAGE__->setup_log; } @@ -32,7 +33,7 @@ is( MyApp->model('Model'), 'MyApp::M::Model', 'M::Model ok' ); is( MyApp->model('Dummy::Model'), 'MyApp::Model::Dummy::Model', 'Model::Dummy::Model ok' ); -isa_ok( MyApp->model('Test::Object'), 'MyApp::Model::Test::Object', 'Test::Object ok' ); +isa_ok( MyApp->model('Test::Object'), 'Some::Test::Object', 'Test::Object ok' ); is( MyApp->controller('Model::Dummy::Model'), 'MyApp::Controller::Model::Dummy::Model', 'Controller::Model::Dummy::Model ok' ); @@ -81,7 +82,12 @@ is ( bless ({stash=>{current_view_instance=> $view, current_view=>'MyApp::V::Vie no warnings 'redefine'; local *Catalyst::Log::warn = sub { $warnings++ }; - like (MyApp->model , qr/^MyApp\::(M|Model)\::/ , 'model() with no defaults returns *something*'); + ok( my $model = MyApp->model ); + + ok( (($model =~ /^MyApp\::(M|Model)\::/) || + $model->isa('Some::Test::Object')), + 'model() with no defaults returns *something*' ); + ok( $warnings, 'model() w/o a default is random, warnings thrown' ); } @@ -160,7 +166,7 @@ is ( MyApp->model , 'MyApp::Model::M', 'default_model in class method ok'); # test accept-context with class rather than instance MyApp->model('M', qw/foo bar/); - is_deeply($args, [qw/foo bar/], '$c->model args passed to ACCEPT_CONTEXT ok'); + is_deeply($args, [qw/foo bar/], 'MyApp->model args passed to ACCEPT_CONTEXT ok'); $c->model('M', qw/foo bar/); @@ -173,7 +179,5 @@ is ( MyApp->model , 'MyApp::Model::M', 'default_model in class method ok'); $c->view('::View::V', qw/foo3 bar3/); is_deeply($args, [qw/foo3 bar3/], 'args passed to ACCEPT_CONTEXT ok'); - undef $args; - MyApp->model('M', qw/foo bar/); - is($args, undef, 'MyApp->model does not invoke ACCEPT_CONTEXT'); + }