X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Funit_core_component_loading.t;h=55ecda066bafe7067fb021461222368f5a2f33eb;hb=e7e4c4697a2a0f13fd8d250cb0b6b080013747b5;hp=5b6a4a7873b47297650ecd0c173505c73261a3a9;hpb=b94b200c22a5c08f9fa18db789914b3bd593f4b5;p=catagits%2FCatalyst-Runtime.git diff --git a/t/unit_core_component_loading.t b/t/unit_core_component_loading.t index 5b6a4a7..55ecda0 100644 --- a/t/unit_core_component_loading.t +++ b/t/unit_core_component_loading.t @@ -1,7 +1,8 @@ # 2 initial tests, and 6 per component in the loop below # (do not forget to update the number of components in test 3 as well) # 5 extra tests for the loading options -use Test::More tests => 2 + 6 * 24 + 5; +# One test for components in inner packages +use Test::More tests => 2 + 6 * 24 + 7 + 1; use strict; use warnings; @@ -63,9 +64,10 @@ sub make_component_file { write_component_file(\@dir_list, $name_final, <NEXT::COMPONENT(\@_); + my \$self = shift->next::method(\@_); no strict 'refs'; *{\__PACKAGE__ . "::whoami"} = sub { return \__PACKAGE__; }; \$self; @@ -81,7 +83,11 @@ foreach my $component (@components) { $component->{name}); } -eval "package $appclass; use Catalyst; __PACKAGE__->setup"; +my $shut_up_deprecated_warnings = q{ + __PACKAGE__->log(Catalyst::Log->new('fatal')); +}; + +eval "package $appclass; use Catalyst; $shut_up_deprecated_warnings __PACKAGE__->setup"; can_ok( $appclass, 'components'); @@ -140,6 +146,7 @@ foreach my $component (@components) { eval qq( package $appclass; use Catalyst; +$shut_up_deprecated_warnings __PACKAGE__->config->{ setup_components } = { search_extra => [ '::Extra' ], except => [ "${appclass}::Controller::Foo" ] @@ -165,9 +172,12 @@ package ${appclass}::Model::TopLevel; use base 'Catalyst::Model'; sub COMPONENT { - my \$self = shift->NEXT::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; } @@ -184,7 +194,7 @@ package ${appclass}::Model::TopLevel::Nested; use base 'Catalyst::Model'; no warnings 'redefine'; -sub COMPONENT { return shift->NEXT::COMPONENT(\@_); } +sub COMPONENT { return shift->next::method(\@_); } 1; EOF @@ -193,4 +203,21 @@ eval "package $appclass; use Catalyst; __PACKAGE__->setup"; is($@, '', "Didn't load component twice"); +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"; + +{ + package InnerComponent::Controller::Test; + use base 'Catalyst::Controller'; +} + +$INC{'InnerComponent/Controller/Test.pm'} = 1; + +eval "package $appclass; use Catalyst; __PACKAGE__->setup"; + +isa_ok($appclass->controller('Test'), 'Catalyst::Controller'); + rmtree($libdir);