update changelog in prep for release
[catagits/CatalystX-Declare.git] / t / 100_complex.t
CommitLineData
a0ebba1d 1#!/usr/bin/env perl
2use strict;
3use warnings;
4
5use FindBin;
6use lib "$FindBin::Bin/lib";
7
744e2821 8use Test::More;
a0ebba1d 9use Catalyst::Test 'TestApp';
10
11# simple stuff
12is get('/foo'), 'Welcome to TestApp!', 'simple root action';
13
14# with arguments
15is get('/foo/with_args/hello/cthulhu'), 'Hello, Cthulhu!', 'simple argument';
16is get('/foo/with_args/at_end/2/3'), 6, 'two arguments at the end';
17is get('/foo/with_args/in_the_middle/3/4/end_of_the_middle'), 24, 'two arguments in the middle';
18is get('/foo/with_args/4/8/fhtagn/15/16/23/42'), '4, 8, 15, 16, 23, 42', 'complex arguments in both';
19
20# under keyword
21is get('/foo/under/23'), 'under 23', 'under as keyword';
22
23# comma separation
24is get('/foo/,comma/iaia'), 'iaia', 'comma separation';
e10b92dd 25
26# nested under
3187b9aa 27is get('/foo/lower/down/the/stream'), 'foo/stream', 'nested under blocks';
a1dd1788 28
29# action roles
30do {
31 local $ENV{TESTAPP_ACTIONROLE} = 1;
32 is get('/foo/with_role'), 'YES', 'fully named action role works';
33};
34do {
35 local $ENV{TESTAPP_ACTIONROLE} = 0;
36 is get('/foo/with_role'), 'NO', 'aliased action role works';
37};
38
39# action class
40is get('/foo/book/Whatever/view/xml'), 'Page 1 of "Whatever" as XML', 'action class was set';
41is get('/foo/book/Fnord/view/html?page=7'), 'Page 7 of "Fnord" as HTML', 'action class was set';
2dde75e7 42
43# final keyword
44is get('/foo/finals/in_front'), 'foo/in_front', 'final syntax element as declarator';
45is get('/foo/finals/final_middle'), 'foo/final_middle', 'final syntax element in the middle';
46is get('/foo/finals/final_at_end'), 'foo/final_at_end', 'final syntax element at the end';
aae7ad1f 47
48# privates
49is get('/foo/expose_not_really_here'), 23, 'private action works';
64baeca0 50
51# specify chain target directly via action
52is get('/foo/pointed/beaver'), 'Your beaver is pointed!', 'chain target specified via action';
856ac9a7 53
54# an action from a role
55is get('/foo/action_from_ctrl_role'), 'foo/action_from_ctrl_role', 'action from controller role';
56
57# an action body that was modified
58is get('/foo/modifier_target'), 'foo/modifier_target modified', 'action was modified by role';
59is get('/foo/surrounded_target'), 'foo/surrounded_target surrounded', 'action was modified with around by role';
60
61# inline classes
62is get('/foo/inline_class'), 'HELLO', 'inline classes work as expected';
744e2821 63
5fb5cef1 64# error handling
ed4a2203 65is get('/foo/wants_integer/butdoesntgetone'), 'no integer', 'validation error causes bad request error';
5fb5cef1 66
eb97acbb 67# fix bug with capture args below under { }
68is get('/foo/lower/down/the/param/3/road/5'), 8, 'capture args and block under work together';
5fb5cef1 69
d14acb87 70# Make sure action roles with parameters pass params to attributes
71is get('/actionparams/first'), 'action_args_first: 100,101', 'actionrole with params';
72is get('/actionparams/second'), 'action_args_second: 200,201', 'actionrole with params (part two)';
e00e30bd 73is get('/actionparams/third'), 'action_args_third: 300,301', 'actionrole with params (part three)';
744e2821 74
a82dd4d2 75is get('/actionparams/forth'), 'action_args_forth: 400,1,401,2', 'actionrole with params (part four)';
12b853ff 76is get('/actionparams/first_app_ns'), 'action_args_first: 100,101', 'actionrole with params (from App NS)';
77is get('/actionparams/first_cat_ns'), 'action_args_first: 100,101', 'actionrole with params (from Cat NS)';
78
a82dd4d2 79# Check deep parsing
80is get('/actionparams/check_deep'), 'action_args_deep: {a=>1,b=>2}', 'actionrole with deep params';
81
744e2821 82done_testing;