test cases for the args0 issue
[catagits/Catalyst-Runtime.git] / t / args0_bug.t
1 use warnings;
2 use strict;
3 use Test::More;
4
5 {
6   package MyApp::Controller::Root;
7   $INC{'MyApp/Controller/Root.pm'} = __FILE__;
8
9   use Moose;
10   use MooseX::MethodAttributes;
11
12   extends 'Catalyst::Controller';
13
14   sub chain_base :Chained(/) CaptureArgs(1) { }
15
16     sub chained_one_args_0  : Chained(chain_base) PathPart('') Args(1) { $_[1]->res->body('chained_one_args_0') }
17     sub chained_one_args_1  : Chained(chain_base) PathPart('') Args(1) { $_[1]->res->body('chained_one_args_1') }
18
19     sub chained_zero_args_0 : Chained(chain_base) PathPart('') Args(0) { $_[1]->res->body('chained_zero_args_0') }
20     sub chained_zero_args_1 : Chained(chain_base) PathPart('') Args(0) { $_[1]->res->body('chained_zero_args_1') }
21
22   MyApp::Controller::Root->config(namespace=>'');
23
24   package MyApp;
25   use Catalyst;
26
27   MyApp->setup;
28 }
29
30 =over
31
32 [debug] Loaded Chained actions:
33 .-----------------------------------------+---------------------------------------------------.
34 | Path Spec                               | Private                                           |
35 +-----------------------------------------+---------------------------------------------------+
36 | /chain_base/*/*                         | /chain_base (1)                                   |
37 |                                         | => /chained_one_args_0 (1)                        |
38 | /chain_base/*/*                         | /chain_base (1)                                   |
39 |                                         | => /chained_one_args_1 (1)                        |
40 | /chain_base/*                           | /chain_base (1)                                   |
41 |                                         | => /chained_zero_args_0 (0)                       |
42 | /chain_base/*                           | /chain_base (1)                                   |
43 |                                         | => /chained_zero_args_1 (0)                       |
44 '-----------------------------------------+---------------------------------------------------'
45
46 =cut
47
48 use Catalyst::Test 'MyApp';
49 {
50    my $res = request '/chain_base/capturearg/arg';
51   is $res->content, 'chained_one_args_1', "request '/chain_base/capturearg/arg'";
52 }
53
54 {
55     my $res = request '/chain_base/capturearg';
56     is $res->content, 'chained_zero_args_1', "request '/chain_base/capturearg'";
57 }
58
59 done_testing;
60
61 __END__
62