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