5 use lib "$FindBin::Bin/../lib";
8 my @complist = map { "TestAppComponent::$_"; } qw/C::Controller M::Model V::View/;
10 is(ref TestAppComponent->comp('TestAppComponent::V::View'), 'TestAppComponent::V::View', 'Explicit return ok');
12 is(ref TestAppComponent->comp('C::Controller'), 'TestAppComponent::C::Controller', 'Two-part return ok');
14 is(ref TestAppComponent->comp('Model'), 'TestAppComponent::M::Model', 'Single part return ok');
16 is_deeply([ TestAppComponent->comp() ], \@complist, 'Empty return ok');
18 # Is this desired behaviour?
19 is_deeply([ TestAppComponent->comp('Foo') ], \@complist, 'Fallthrough return ok');
23 is_deeply( [ map { ref $_ } TestAppComponent->comp( qr{Model} ) ], [ 'TestAppComponent::M::Model' ], 'regexp ok' );
27 no warnings 'redefine';
28 local *Catalyst::Log::warn = sub { $warnings++ };
30 is_deeply( [ TestAppComponent->comp('::M::Model') ], \@complist, 'no reulsts for regexp fallback');
31 ok( $warnings, 'regexp fallback warnings' );
39 my @expected = qw( TestAppComponent::C::Controller TestAppComponent::M::Model );
40 my @got = map { ref $_ } sort TestAppComponent->comp( qr{::[MC]::} );
41 is_deeply( \@got, \@expected, 'multiple results from regexp ok' );
46 is_deeply( scalar TestAppComponent->comp( qr{DNE} ), 0, 'no results for failed search' );
50 #checking @args passed to ACCEPT_CONTEXT
56 *TestAppComponent::M::Model::ACCEPT_CONTEXT = sub { my ($self, $c, @args) = @_; $args= \@args};
59 my $c = bless {}, 'TestAppComponent';
61 $c->component('TestAppComponent::M::Model', qw/foo bar/);
62 is_deeply($args, [qw/foo bar/], 'args passed to ACCEPT_CONTEXT ok');
64 $c->component('M::Model', qw/foo2 bar2/);
65 is_deeply($args, [qw/foo2 bar2/], 'args passed to ACCEPT_CONTEXT ok');