Commit | Line | Data |
75f37967 |
1 | #!/usr/bin/env perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | use Test::More tests => 4; |
6 | |
c9c41e4d |
7 | my $app = 'MyApp'; |
75f37967 |
8 | |
9 | my $foo = Foo->COMPONENT($app, { args => 'yes' }); |
10 | is $foo->{args}, 'yes', 'foo created'; |
c9c41e4d |
11 | is $foo->context->app, 'oh yeah', 'got app'; |
75f37967 |
12 | |
13 | my $ctx = { ctx => 'it is' }; |
14 | my $foo2 = $foo->ACCEPT_CONTEXT($ctx); |
15 | is $foo, $foo2, 'foo and foo2 are the same ref'; |
16 | is $foo->context->{ctx}, 'it is', 'got ctx'; |
17 | |
18 | { |
19 | package Foo; |
20 | use base qw/Catalyst::Component::ACCEPT_CONTEXT Catalyst::Component/; |
21 | |
22 | sub new { |
23 | my $class = shift; |
c9c41e4d |
24 | return $class->next::method(@_); |
75f37967 |
25 | } |
26 | |
c9c41e4d |
27 | package MyApp; |
28 | use Catalyst; |
29 | sub app { 'oh yeah' } |
75f37967 |
30 | } |