removed NEXT stuff
[catagits/Catalyst-Plugin-ConfigLoader-Environment.git] / t / 01-live.t
CommitLineData
0580e0f8 1#!/usr/bin/perl
2# 01-live.t
3# Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>
4
5use Test::More tests => 12;
6use FindBin qw($Bin);
7use lib "$Bin/lib";
8BEGIN {
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"}%;
17
18}
19
20use Catalyst::Test 'TestApp';
21
22ok(my $r = request('/'), 'request /');
23ok($r->is_success, 'that worked');
24
25my $config = eval $r->content;
26ok(ref $config, 'got config');
27
28is($config->{foo}, 'foo', 'got foo');
29is($config->{bar}, 'bar', 'got bar');
30is($config->{foo_bar_baz}, 'quux', 'got foo_bar_baz');
31is_deeply($config->{quux}, [1,2,3,4], 'JSON for simple param');
32
33my $view = get('/foo/foo');
34is($view, "Test View's foo!", 'got View::TestView->foo');
35
36$view = get('/foo/bar');
37is($view, "Test View's bar!", 'got View::TestView->bar');
38
39$view = get('/foo/quux');
40eval $view;
41no warnings 'once';
42is_deeply($quux, [1,2,3,"Test View's quux!",{ foo => 'bar'}],
43 'JSON for :: sub-param');
44
45$r = request('/model');
46ok($r->is_success, 'got /model');
47my $model_attributes = eval $r->content;
48is_deeply($model_attributes,
49 {
50 foo => 'bar', # From __PACKAGE__ default config
37564e20 51 bar => 'baz', # Merged from my environment hash,
52 catalyst_component_name => 'TestApp::Model::TestModel',
0580e0f8 53 },
54 'JSON for top-level :: param with hash merge');