3 # Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>
5 use Test::More tests => 12;
9 $ENV{TESTAPP_foo} = 'foo';
10 $ENV{TESTAPP_bar} = 'bar';
11 $ENV{TESTAPP_foo_bar_baz} = 'quux';
12 $ENV{TESTAPP_quux} = q%[1,2,3,4]%;
13 $ENV{TESTAPP_View::TestView_foo} = "Test View's foo!";
14 $ENV{TESTAPP_View::TestView_quux} = q%[1,2,3,"Test View's quux!",{"foo":"bar"}]%;
15 $ENV{TESTAPP_View__TestView_bar} = "Test View's bar!";
16 $ENV{TESTAPP_Model__TestModel} = q%{"bar":"baz"}%;
20 use Catalyst::Test 'TestApp';
22 ok(my $r = request('/'), 'request /');
23 ok($r->is_success, 'that worked');
25 my $config = eval $r->content;
26 ok(ref $config, 'got config');
28 is($config->{foo}, 'foo', 'got foo');
29 is($config->{bar}, 'bar', 'got bar');
30 is($config->{foo_bar_baz}, 'quux', 'got foo_bar_baz');
31 is_deeply($config->{quux}, [1,2,3,4], 'JSON for simple param');
33 my $view = get('/foo/foo');
34 is($view, "Test View's foo!", 'got View::TestView->foo');
36 $view = get('/foo/bar');
37 is($view, "Test View's bar!", 'got View::TestView->bar');
39 $view = get('/foo/quux');
42 is_deeply($quux, [1,2,3,"Test View's quux!",{ foo => 'bar'}],
43 'JSON for :: sub-param');
45 $r = request('/model');
46 ok($r->is_success, 'got /model');
47 my $model_attributes = eval $r->content;
48 is_deeply($model_attributes,
50 foo => 'bar', # From __PACKAGE__ default config
51 bar => 'baz', # Merged from my environment hash
53 'JSON for top-level :: param with hash merge');