X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Farg_constraints.t;h=c1e3733ce9c95e30ae4032c4ee9de1bb22efe185;hp=cb4d8cf03a24100558a449c8241d1199617e04d8;hb=0f0fedb2b03e13e16636b61fd5e82b6563d2ee9c;hpb=afa7a6c9f9b0b788c6c165231fbb571a9d8b7a37 diff --git a/t/arg_constraints.t b/t/arg_constraints.t index cb4d8cf..c1e3733 100644 --- a/t/arg_constraints.t +++ b/t/arg_constraints.t @@ -198,6 +198,67 @@ BEGIN { MyApp::Controller::Root->config(namespace=>''); + package MyApp::Controller::Autoclean; + $INC{'MyApp/Controller/Autoclean.pm'} = __FILE__; + + use Moose; + use MooseX::MethodAttributes; + use namespace::autoclean -except => 'Int'; + + use MyApp::Types qw/Int/; + + extends 'Catalyst::Controller'; + + sub an_int :Local Args(Int) { + my ($self, $c, $int) = @_; + $c->res->body('an_int (autoclean)'); + } + + MyApp::Controller::Autoclean->config(namespace=>'autoclean'); + + package MyApp::Role; + $INC{'MyApp/Role.pm'} = __FILE__; + + use Moose::Role; + use MooseX::MethodAttributes::Role; + use MyApp::Types qw/Int/; + + sub an_int :Local Args(Int) { + my ($self, $c, $int) = @_; + $c->res->body('an_int (withrole)'); + } + + sub an_int_ns :Local Args(MyApp::Types::Int) { + my ($self, $c, $int) = @_; + $c->res->body('an_int (withrole)'); + } + + package MyApp::BaseController; + $INC{'MyApp/BaseController.pm'} = __FILE__; + + use Moose; + use MooseX::MethodAttributes; + use MyApp::Types qw/Int/; + + extends 'Catalyst::Controller'; + + sub from_parent :Local Args(Int) { + my ($self, $c, $id) = @_; + $c->res->body("from_parent $id"); + } + + package MyApp::Controller::WithRole; + $INC{'MyApp/Controller/WithRole.pm'} = __FILE__; + + use Moose; + use MooseX::MethodAttributes; + + extends 'MyApp::BaseController'; + + with 'MyApp::Role'; + + MyApp::Controller::WithRole->config(namespace=>'withrole'); + package MyApp; use Catalyst; @@ -508,4 +569,28 @@ SKIP: { } +{ + my $res = request '/autoclean/an_int/1'; + is $res->content, 'an_int (autoclean)'; +} + +{ + my $res = request '/withrole/an_int_ns/S'; + is $res->content, 'default'; +} + +{ + my $res = request '/withrole/an_int_ns/111'; + is $res->content, 'an_int (withrole)'; +} + +{ + my $res = request '/withrole/an_int/1'; + is $res->content, 'an_int (withrole)'; +} + +{ + my $res = request '/withrole/from_parent/1'; + is $res->content, 'from_parent 1'; +} done_testing;