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=2103bf21e7454f1609ea7a958bbcb662971b118d;hp=5ef97e53ed916118423f32a7e3c6b7d559ffa1dd;hb=1d285816f88ccd8b81e733565ca4363140b75ec8;hpb=50b07d604b372d9487863120b9df9c813bbe7334 diff --git a/t/arg_constraints.t b/t/arg_constraints.t index 5ef97e5..2103bf2 100644 --- a/t/arg_constraints.t +++ b/t/arg_constraints.t @@ -16,14 +16,14 @@ BEGIN { use strict; use warnings; - + use Type::Utils -all; use Types::Standard -types; use Type::Library -base, -declare => qw( UserId Heart User ContextLike ); - extends "Types::Standard"; + extends "Types::Standard"; class_type User, { class => "MyApp::Model::User::user" }; duck_type ContextLike, [qw/model/]; @@ -152,7 +152,7 @@ BEGIN { sub any_priority_link_any :Chained(link_any) PathPart('') Args(1) { $_[1]->res->body('any_priority_link_any') } sub int_priority_link_any :Chained(link_any) PathPart('') Args(Int) { $_[1]->res->body('int_priority_link_any') } - + sub link_int :Chained(chain_base) PathPart('') CaptureArgs(Int) { } sub any_priority_link :Chained(link_int) PathPart('') Args(1) { $_[1]->res->body('any_priority_link') } @@ -203,7 +203,7 @@ BEGIN { use Moose; use MooseX::MethodAttributes; - use namespace::autoclean; + use namespace::clean -except => [ 'meta' ]; use MyApp::Types qw/Int/; @@ -228,13 +228,32 @@ BEGIN { $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 'Catalyst::Controller'; + extends 'MyApp::BaseController'; with 'MyApp::Role'; @@ -463,16 +482,6 @@ SKIP: { is $res->content, 'default', "request '/stringy_enum/a'"; } -{ - my $res = request '/autoclean/an_int/1'; - is $res->content, 'an_int (autoclean)'; -} - -{ - my $res = request '/withrole/an_int/1'; - is $res->content, 'an_int (withrole)'; -} - =over | /chain_base/*/*/*/*/*/* | /chain_base (1) @@ -560,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;