1 use Test::More tests => 11;
7 my @complist = map { "MyApp::$_"; } qw/C::Controller M::Model V::View/;
12 use base qw/Catalyst/;
14 __PACKAGE__->components({ map { ($_, $_) } @complist });
16 # this is so $c->log->warn will work
17 __PACKAGE__->setup_log;
20 is(MyApp->comp('MyApp::V::View'), 'MyApp::V::View', 'Explicit return ok');
22 is(MyApp->comp('C::Controller'), 'MyApp::C::Controller', 'Two-part return ok');
24 is(MyApp->comp('Model'), 'MyApp::M::Model', 'Single part return ok');
29 no warnings 'redefine';
30 local *Catalyst::Log::warn = sub { $warnings++ };
32 is(MyApp->comp('::M::'), 'MyApp::M::Model', 'Regex return ok');
33 ok( $warnings, 'regexp fallback for comp() warns' );
36 is_deeply([ MyApp->comp() ], \@complist, 'Empty return ok');
38 # Is this desired behaviour?
39 is_deeply([ MyApp->comp('Foo') ], \@complist, 'Fallthrough return ok');
43 is_deeply( [ MyApp->comp( qr{Model} ) ], [ 'MyApp::M::Model'], 'regexp ok' );
48 my @expected = qw( MyApp::C::Controller MyApp::M::Model );
49 is_deeply( [ MyApp->comp( qr{::[MC]::} ) ], \@expected, 'multiple results fro regexp ok' );
54 is_deeply( scalar MyApp->comp( qr{DNE} ), 0, 'no results for failed search' );