have to use a real app in test due to changes in runtime COMPONENT
[catagits/Catalyst-Component-ACCEPT_CONTEXT.git] / t / preserve-object.t
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5 use Test::More tests => 4;
6
7 my $app = 'MyApp';
8
9 my $foo = Foo->COMPONENT($app, { args => 'yes' });
10 is $foo->{args}, 'yes', 'foo created';
11 is $foo->context->app, 'oh yeah', 'got app';
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;
24         return $class->next::method(@_);
25     }
26
27     package MyApp;
28     use Catalyst;
29     sub app { 'oh yeah' }
30 }