X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Funit_core_component_loading.t;h=1944ab6e63b266e9009948e4d17aeeff10d3c598;hb=a2aac3b8867dea286d03eba07a6fbe2e237cf1ae;hp=42f1eac39c9de3e58ed3d413d60223b2e849e3c3;hpb=e1dd56e6f190fe600d63c3d3763efb171f67b274;p=catagits%2FCatalyst-Runtime.git diff --git a/t/unit_core_component_loading.t b/t/unit_core_component_loading.t index 42f1eac..1944ab6 100644 --- a/t/unit_core_component_loading.t +++ b/t/unit_core_component_loading.t @@ -2,7 +2,7 @@ # (do not forget to update the number of components in test 3 as well) # 5 extra tests for the loading options # One test for components in inner packages -use Test::More tests => 2 + 6 * 24 + 5 + 1; +use Test::More tests => 2 + 6 * 24 + 8 + 1; use strict; use warnings; @@ -175,6 +175,9 @@ sub COMPONENT { my \$self = shift->next::method(\@_); no strict 'refs'; *{\__PACKAGE__ . "::whoami"} = sub { return \__PACKAGE__; }; + *${appclass}::Model::TopLevel::GENERATED::ACCEPT_CONTEXT = sub { + return bless {}, 'FooBarBazQuux'; + }; \$self; } @@ -190,8 +193,10 @@ write_component_file([$libdir, $appclass, 'Model', 'TopLevel'], 'Nested', <next::method(\@_); } +sub COMPONENT { \$called++;return shift->next::method(\@_); } +sub called { return \$called }; 1; EOF @@ -199,6 +204,11 @@ EOF eval "package $appclass; use Catalyst; __PACKAGE__->setup"; is($@, '', "Didn't load component twice"); +is($appclass->model('TopLevel::Nested')->called,1, 'COMPONENT called once'); + +ok($appclass->model('TopLevel::Generated'), 'Have generated model'); +is(ref($appclass->model('TopLevel::Generated')), 'FooBarBazQuux', + 'ACCEPT_CONTEXT in generated inner package fired as expected'); $appclass = "InnerComponent";