1 package TestAppComponents;
6 sub locate_components {
8 push @comps, "TestAppComponents::$_" for qw/
13 Controller::Bar::Bar::Bar::Foo
14 Controller::Bar::Bar::Foo
21 Model::Bar::Bar::Bar::Foo
29 View::Bar::Bar::Bar::Foo
37 __PACKAGE__->components( {} );
39 # this is so $c->container will work
40 __PACKAGE__->setup_config;
42 # this is so $c->log->warn will work
43 __PACKAGE__->setup_log;
45 for my $component (TestAppComponents->locate_components) {
50 use base 'Catalyst::Component';
62 my @comps = TestAppComponents->locate_components;
68 no warnings 'redefine';
70 local *Catalyst::Log::warn = sub { $warnings++ };
71 local *Catalyst::Utils::ensure_class_loaded = sub { my $class = shift; push @loaded_comps, $class; };
73 eval { TestAppComponents->setup_components };
75 ok( !$@, "setup_components doesnt die" );
76 ok( $warnings, "it warns about deprecated names" );
77 is_deeply( \@comps, \@loaded_comps, 'all components loaded' );
80 my @controllers = @comps[0..7];
81 my @models = @comps[8..15];
82 my @views = @comps[16..23];
83 my $container = TestAppComponents->container;
86 [ sort $container->get_sub_container('controller')->get_service_list ],
87 [ sort @controllers ],
88 'controllers are in the container',
92 [ sort TestAppComponents->controllers ],
93 [ sort @controllers ],
94 'controllers are listed correctly by $c->controllers()',
98 [ sort $container->get_sub_container('model')->get_service_list ],
100 'models are in the container',
104 [ sort TestAppComponents->models ],
106 'models are listed correctly by $c->models()',
110 [ sort $container->get_sub_container('view')->get_service_list ],
112 'views are in the container',
116 [ sort TestAppComponents->views ],
118 'views are listed correctly by $c->views()',
122 [ sort keys %{ TestAppComponents->components } ],
124 'all components are in the components accessor'