X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Funit_core_mvc.t;h=549d758ca68791fb7a9acdfe3ff5a0a14c512e61;hb=361359b59a0523c90962bc4f7a78562630fafe80;hp=74b4ecf6a9e517c9c84aa7ec83ec7b1e18da364b;hpb=fb5f42422b1ef1a4cc64ddfd83836c8c1d89bb2c;p=catagits%2FCatalyst-Runtime.git diff --git a/t/unit_core_mvc.t b/t/unit_core_mvc.t index 74b4ecf..549d758 100644 --- a/t/unit_core_mvc.t +++ b/t/unit_core_mvc.t @@ -1,4 +1,4 @@ -use Test::More tests => 40; +use Test::More tests => 44; use strict; use warnings; @@ -108,7 +108,7 @@ is ( MyApp->model , 'MyApp::Model::M', 'default_model in class method ok'); is_deeply( [ MyApp->controller( qr{Dummy\::Model$} ) ], [ 'MyApp::Controller::Model::Dummy::Model' ], 'regexp controller ok' ); is_deeply( [ MyApp->model( qr{Dum{2}y} ) ], [ 'MyApp::Model::Dummy::Model' ], 'regexp model ok' ); - # ACCEPT_CONTEXT w/ qr{} + # object w/ qr{} is_deeply( [ MyApp->model( qr{Test} ) ], [ MyApp->components->{'MyApp::Model::Test::Object'} ], 'Object returned' ); { @@ -116,11 +116,14 @@ is ( MyApp->model , 'MyApp::Model::M', 'default_model in class method ok'); no warnings 'redefine'; local *Catalyst::Log::warn = sub { $warnings++ }; - # ACCEPT_CONTEXT w/ regexp fallback + # object w/ regexp fallback is_deeply( [ MyApp->model( 'Test' ) ], [ MyApp->components->{'MyApp::Model::Test::Object'} ], 'Object returned' ); ok( $warnings, 'regexp fallback warnings' ); } + is_deeply( [ MyApp->view('MyApp::V::View$') ], [ 'MyApp::V::View' ], 'Explicit return ok'); + is_deeply( [ MyApp->controller('MyApp::C::Controller$') ], [ 'MyApp::C::Controller' ], 'Explicit return ok'); + is_deeply( [ MyApp->model('MyApp::M::Model$') ], [ 'MyApp::M::Model' ], 'Explicit return ok'); } { @@ -144,14 +147,20 @@ is ( MyApp->model , 'MyApp::Model::M', 'default_model in class method ok'); } #checking @args passed to ACCEPT_CONTEXT -my $args; { + my $args; + no warnings; *MyApp::Model::M::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args}; *MyApp::View::V::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args}; -} -MyApp->model('M', qw/foo bar/); -is_deeply($args, [qw/foo bar/], '$c->model args passed to ACCEPT_CONTEXT ok'); -MyApp->view('V', qw/baz moo/); -is_deeply($args, [qw/baz moo/], '$c->view args passed to ACCEPT_CONTEXT ok'); + MyApp->model('M', qw/foo bar/); + is_deeply($args, [qw/foo bar/], '$c->model args passed to ACCEPT_CONTEXT ok'); + + my $x = MyApp->view('V', qw/foo2 bar2/); + is_deeply($args, [qw/foo2 bar2/], '$c->view args passed to ACCEPT_CONTEXT ok'); + + # regexp fallback + MyApp->view('::View::V', qw/foo3 bar3/); + is_deeply($args, [qw/foo3 bar3/], 'args passed to ACCEPT_CONTEXT ok'); +}