setting correct return value for components
[catagits/Catalyst-Runtime.git] / t / aggregate / unit_core_container_custom_container.t
1 use strict;
2 use warnings;
3 use Test::More;
4
5 # first, test if it loads Catalyst::Container when
6 # no custom container exists
7 {
8     package ContainerTestApp;
9     use Moose;
10     extends 'Catalyst';
11
12     __PACKAGE__->setup_config();
13     __PACKAGE__->setup_log();
14 }
15
16 my $container = ContainerTestApp->container;
17
18 # 'is' instead of 'isa_ok', because I want it to be only Catalyst::Container
19 # and not some subclass
20 is( ref $container, 'Catalyst::IOC::Container', 'The container is Catalyst::IOC::Container, not a subclass');
21
22 # now, check if it loads the subclass when it exists
23 {
24     package CustomContainerTestApp::Container;
25     use Moose;
26     extends 'Catalyst::IOC::Container';
27
28     sub my_custom_method { 1 }
29 }
30
31 {
32     package CustomContainerTestApp;
33     use Moose;
34     BEGIN { extends 'Catalyst' };
35
36     __PACKAGE__->setup_config();
37 }
38
39 $container = CustomContainerTestApp->container;
40
41 isa_ok($container, 'CustomContainerTestApp::Container');
42 isa_ok($container, 'Catalyst::IOC::Container');
43 can_ok($container, 'my_custom_method');
44 ok( eval { $container->my_custom_method }, 'executes the method correctly');
45
46 done_testing;