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) {
46 my $classname = "$component";
51 use base 'Catalyst::Component';
63 my @comps = TestAppComponents->locate_components;
69 no warnings 'redefine';
71 local *Catalyst::Log::warn = sub { $warnings++ };
72 local *Catalyst::Utils::ensure_class_loaded = sub { my $class = shift; push @loaded_comps, $class; };
74 eval { TestAppComponents->setup_components };
76 ok( !$@, "setup_components doesnt die" );
77 ok( $warnings, "it warns about deprecated names" );
78 is_deeply( \@comps, \@loaded_comps, 'all components loaded' );
81 my @controllers = @comps[0..7];
82 my @models = @comps[8..15];
83 my @views = @comps[16..23];
84 my $container = TestAppComponents->container;
87 [ sort $container->get_sub_container('controller')->get_service_list ],
88 [ sort @controllers ],
89 'controllers are in the container',
93 [ sort $container->get_sub_container('model')->get_service_list ],
95 'models are in the container',
99 [ sort $container->get_sub_container('view')->get_service_list ],
101 'views are in the container',
105 [ sort keys %{ TestAppComponents->components } ],
107 'all components are in the components accessor'