From: John Napiorkowski Date: Tue, 11 Aug 2015 19:23:05 +0000 (-0500) Subject: role test case X-Git-Tag: 5.90100~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=afa7a6c9f9b0b788c6c165231fbb571a9d8b7a37 role test case --- diff --git a/t/arg_constraints.t b/t/arg_constraints.t index 2a005b7..cb4d8cf 100644 --- a/t/arg_constraints.t +++ b/t/arg_constraints.t @@ -43,6 +43,23 @@ BEGIN { } { + package MyApp::Role::Controller; + $INC{'MyApp/Role/Controller.pm'} = __FILE__; + + use Moose::Role; + use MooseX::MethodAttributes::Role; + use MyApp::Types qw/Int Str/; + + sub role_str :Path('role_test') Args(Str) { + my ($self, $c, $arg) = @_; + $c->res->body('role_str'.$arg); + } + + sub role_int :Path('role_test') Args(Int) { + my ($self, $c, $arg) = @_; + $c->res->body('role_int'.$arg); + } + package MyApp::Model::User; $INC{'MyApp/Model/User.pm'} = __FILE__; @@ -70,6 +87,8 @@ BEGIN { use MyApp::Types qw/Tuple Int Str StrMatch ArrayRef UserId User Heart/; extends 'Catalyst::Controller'; + with 'MyApp::Role::Controller'; + sub user :Local Args(UserId) { my ($self, $c, $int) = @_; @@ -476,4 +495,17 @@ SKIP: { } +# Test Roles + +{ + my $res = request '/role_test/1'; + is $res->content, 'role_int1'; +} + +{ + my $res = request '/role_test/a'; + is $res->content, 'role_stra'; +} + + done_testing;