Tests for the modules with a keep_stash option
[catagits/Catalyst-View-Component-SubInclude.git] / t / 02-app-keepstash.t
CommitLineData
f78902ea 1use strict;
2use warnings;
3use FindBin qw/$Bin/;
4use lib "$Bin/lib";
5
6use Test::More;
7use Catalyst::Test 'KeepStash';
8
9my $content;
10
11$content = get('/subrequest_keepstash_index');
12
13# Because of the way SubRequest and Catalyst interact, the first level of the stash will get copied. On return to the root request,
14# the first level of the stash will remain intact. Deep datastructures will be changed by subrequests, though
15like($content, qr/-------ROOT------------\nShallow value: 5\nDeep Value: 9\n/, 'Got expected values in the stash');
16like($content, qr/-------1st-------------\nShallow value: 6\nDeep Value: 10\nNew Value: \n/, 'Got expected values in the 1st call');
17like($content, qr/-------2nd-------------\nShallow value: 6\nDeep Value: 11\nNew Value: \n/, 'Got expected values in the 2nd call');
18
19$content = get('/visit_keepstash_index');
20like($content, qr/-------ROOT------------\nShallow value: 5\nDeep Value: 9\n/, 'Got expected values in the stash');
21like($content, qr/-------1st-------------\nShallow value: 6\nDeep Value: 10\nNew Value: \n/, 'Got expected values in the 1st call');
22like($content, qr/-------2nd-------------\nShallow value: 7\nDeep Value: 11\nNew Value: new\n/, 'Got expected values in the 2nd call');
23
24done_testing;