X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Finject_component_util.t;h=5b9c2d0eaa73830e6213888770f921abbdc64ef0;hb=718a1619e553805a9f1ecade8b2b0231275909f3;hp=c757d9c36f83049626d12b370a95d92a610d0382;hpb=ec4d72594fb7a701c2f36e85ecf9a680ca1abba2;p=catagits%2FCatalyst-Runtime.git diff --git a/t/inject_component_util.t b/t/inject_component_util.t index c757d9c..5b9c2d0 100644 --- a/t/inject_component_util.t +++ b/t/inject_component_util.t @@ -2,12 +2,33 @@ use strict; use warnings; use Test::More; use Catalyst::Utils; - +use FindBin; +use lib "$FindBin::Bin/lib"; + BEGIN { +package RoleTest1; + +use Moose::Role; + +sub aaa { 'aaa' } + +package RoleTest2; + +use Moose::Role; + +sub bbb { 'bbb' } + package Model::Banana; use base qw/Catalyst::Model/; + +package Model::BananaMoose; +use Moose; +extends 'Catalyst::Model'; + +Model::BananaMoose->meta->make_immutable; + package TestCatalyst; $INC{'TestCatalyst.pm'} = 1; use Catalyst::Runtime '5.70'; @@ -20,9 +41,11 @@ use Catalyst; after 'setup_components' => sub { my $self = shift; Catalyst::Utils::inject_component( into => __PACKAGE__, component => 'Model::Banana' ); - Catalyst::Utils::inject_component( into => __PACKAGE__, component => 't::Test::Apple' ); + Catalyst::Utils::inject_component( into => __PACKAGE__, component => 'Test::Apple' ); Catalyst::Utils::inject_component( into => __PACKAGE__, component => 'Model::Banana', as => 'Cherry' ); - Catalyst::Utils::inject_component( into => __PACKAGE__, component => 't::Test::Apple', as => 'Apple' ); + Catalyst::Utils::inject_component( into => __PACKAGE__, component => 'Model::BananaMoose', as => 'CherryMoose', traits => ['RoleTest1', 'RoleTest2'] ); + Catalyst::Utils::inject_component( into => __PACKAGE__, component => 'Test::Apple', as => 'Apple' ); + Catalyst::Utils::inject_component( into => __PACKAGE__, component => 'Test::Apple', as => 'Apple2', traits => ['RoleTest1', 'RoleTest2'] ); }; TestCatalyst->config( 'home' => '.' ); @@ -35,7 +58,11 @@ package main; use Catalyst::Test qw/TestCatalyst/; -ok( TestCatalyst->controller( $_ ) ) for qw/ Apple t::Test::Apple /; +ok( TestCatalyst->controller( $_ ) ) for qw/ Apple Test::Apple /; ok( TestCatalyst->model( $_ ) ) for qw/ Banana Cherry /; +is( TestCatalyst->controller('Apple2')->aaa, 'aaa'); +is( TestCatalyst->controller('Apple2')->bbb, 'bbb'); +is( TestCatalyst->model('CherryMoose')->aaa, 'aaa'); +is( TestCatalyst->model('CherryMoose')->bbb, 'bbb'); done_testing;