c757d9c36f83049626d12b370a95d92a610d0382
[catagits/Catalyst-Runtime.git] / t / inject_component_util.t
1 use strict;
2 use warnings; 
3 use Test::More;
4 use Catalyst::Utils;
5  
6 BEGIN {
7 package Model::Banana;
8  
9 use base qw/Catalyst::Model/;
10  
11 package TestCatalyst; $INC{'TestCatalyst.pm'} = 1;
12  
13 use Catalyst::Runtime '5.70';
14  
15 use Moose;
16 BEGIN { extends qw/Catalyst/ }
17  
18 use Catalyst;
19  
20 after 'setup_components' => sub {
21     my $self = shift;
22     Catalyst::Utils::inject_component( into => __PACKAGE__, component => 'Model::Banana' );
23     Catalyst::Utils::inject_component( into => __PACKAGE__, component => 't::Test::Apple' );
24     Catalyst::Utils::inject_component( into => __PACKAGE__, component => 'Model::Banana', as => 'Cherry' );
25     Catalyst::Utils::inject_component( into => __PACKAGE__, component => 't::Test::Apple', as => 'Apple' );
26 };
27  
28 TestCatalyst->config( 'home' => '.' );
29  
30 TestCatalyst->setup;
31  
32 }
33  
34 package main;
35  
36 use Catalyst::Test qw/TestCatalyst/;
37  
38 ok( TestCatalyst->controller( $_ ) ) for qw/ Apple t::Test::Apple /;
39 ok( TestCatalyst->model( $_ ) ) for qw/ Banana Cherry /;
40
41 done_testing;