do not run tests that fail when debug mode is active
[catagits/Catalyst-Runtime.git] / t / middleware-stash.t
1 use warnings;
2 use strict;
3
4 {
5
6   package MyAppChild::Controller::User;
7   $INC{'MyAppChild/Controller/User.pm'} = __FILE__;
8
9   use base 'Catalyst::Controller';
10   use Test::More;
11
12   sub stash :Local {
13     my ($self, $c) = @_;
14     $c->stash->{inner} = "inner";
15     $c->res->body( "inner: ${\$c->stash->{inner}}, outer: ${\$c->stash->{outer}}");
16
17     use Devel::Dwarn;
18     my $stash = $c->stash;
19     Dwarn $stash;
20
21     is_deeply [sort {$a cmp $b} keys($c->stash)], ['inner','outer'], 'both keys in stash';
22   }
23
24   package MyAppChild;
25   $INC{'MyAppChild.pm'} = __FILE__;
26
27   use Catalyst;
28   MyAppChild->setup;
29
30   package MyAppParent::Controller::User;
31   $INC{'MyAppParent/Controller/User.pm'} = __FILE__;
32
33   use base 'Catalyst::Controller';
34   use Test::More;
35
36   sub stash :Local {
37     my ($self, $c) = @_;
38     $c->stash->{outer} = "outer";
39     $c->res->from_psgi_response( MyAppChild->to_app->($c->req->env) );
40
41     is_deeply [keys($c->stash)], ['outer'], 'only one key in stash';
42   }
43
44   package MyAppParent;
45   use Catalyst;
46   MyAppParent->setup;
47
48 }
49
50 use Test::More;
51 use Catalyst::Test 'MyAppParent';
52
53 my $res = request '/user/stash';
54 is $res->content, 'inner: inner, outer: outer', 'got expected response';
55
56 done_testing;