have to use a real app in test due to changes in runtime COMPONENT
[catagits/Catalyst-Component-ACCEPT_CONTEXT.git] / t / preserve-object.t
CommitLineData
75f37967 1#!/usr/bin/env perl
2
3use strict;
4use warnings;
5use Test::More tests => 4;
6
c9c41e4d 7my $app = 'MyApp';
75f37967 8
9my $foo = Foo->COMPONENT($app, { args => 'yes' });
10is $foo->{args}, 'yes', 'foo created';
c9c41e4d 11is $foo->context->app, 'oh yeah', 'got app';
75f37967 12
13my $ctx = { ctx => 'it is' };
14my $foo2 = $foo->ACCEPT_CONTEXT($ctx);
15is $foo, $foo2, 'foo and foo2 are the same ref';
16is $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}