From: Florian Ragwitz Date: Wed, 3 Sep 2008 06:03:36 +0000 (+0000) Subject: Fix ACCEPT_COMPONENT tests. X-Git-Tag: 5.8000_03~74 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=15a32cd53bc6ab00aa2e70f214486483278145e9 Fix ACCEPT_COMPONENT tests. As of r8334 MyApp->component doesn't invoke ACCEPT_COMPONENT anymore. --- diff --git a/t/unit_core_component.t b/t/unit_core_component.t index 250960a..368f163 100644 --- a/t/unit_core_component.t +++ b/t/unit_core_component.t @@ -73,16 +73,20 @@ is_deeply([ MyApp->comp('Foo') ], \@complist, 'Fallthrough return ok'); { my $args; - no warnings; - *MyApp::M::Model::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args}; + { + no warnings 'once'; + *MyApp::M::Model::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args}; + } + + my $c = bless {}, 'MyApp'; - MyApp->component('MyApp::M::Model', qw/foo bar/); + $c->component('MyApp::M::Model', qw/foo bar/); is_deeply($args, [qw/foo bar/], 'args passed to ACCEPT_CONTEXT ok'); - MyApp->component('M::Model', qw/foo2 bar2/); + $c->component('M::Model', qw/foo2 bar2/); is_deeply($args, [qw/foo2 bar2/], 'args passed to ACCEPT_CONTEXT ok'); - MyApp->component('Mode', qw/foo3 bar3/); + $c->component('Mode', qw/foo3 bar3/); is_deeply($args, [qw/foo3 bar3/], 'args passed to ACCEPT_CONTEXT ok'); } diff --git a/t/unit_core_mvc.t b/t/unit_core_mvc.t index 549d758..f6b9011 100644 --- a/t/unit_core_mvc.t +++ b/t/unit_core_mvc.t @@ -150,17 +150,21 @@ is ( MyApp->model , 'MyApp::Model::M', 'default_model in class method ok'); { 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}; + { + no warnings 'once'; + *MyApp::Model::M::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args}; + *MyApp::View::V::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args}; + } + + my $c = bless {}, 'MyApp'; - MyApp->model('M', qw/foo bar/); + $c->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/); + my $x = $c->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/); + $c->view('::View::V', qw/foo3 bar3/); is_deeply($args, [qw/foo3 bar3/], 'args passed to ACCEPT_CONTEXT ok'); }