added tests for ignorance against modifier signatures
Robert 'phaylon' Sedlacek [Thu, 6 Aug 2009 19:22:59 +0000 (21:22 +0200)]
t/051_modifier_signatures.t [new file with mode: 0644]
t/lib/TestApp/Controller/ModifierSignatures.pm [new file with mode: 0644]
t/lib/TestApp/ControllerRole/ModifierSignatures.pm [new file with mode: 0644]

diff --git a/t/051_modifier_signatures.t b/t/051_modifier_signatures.t
new file mode 100644 (file)
index 0000000..531a502
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More; 
+use Catalyst::Test 'TestApp';
+
+is get('/modsig/foo/2/3'),      'modifiersignatures/foo modified', 'intended arguments work';
+is get('/modsig/foo/2'),        'Page Not Found', 'missing argument leads to 404';
+is get('/modsig/foo/2/3/4'),    'Page Not Found', 'one argument too many leads to 404';
+is get('/modsig/foo/a/b'),      'Bad Request', 'invalid arguments lead to bad request';
+
+
+done_testing;
diff --git a/t/lib/TestApp/Controller/ModifierSignatures.pm b/t/lib/TestApp/Controller/ModifierSignatures.pm
new file mode 100644 (file)
index 0000000..c3f3521
--- /dev/null
@@ -0,0 +1,15 @@
+use CatalystX::Declare;
+
+controller TestApp::Controller::ModifierSignatures 
+    with TestApp::ControllerRole::ModifierSignatures {
+
+    action base as 'modsig' under '/';
+
+    final action foo (Int $x, Int $y) under base {
+        $ctx->response->body( $ctx->action->reverse );
+    }
+
+    final action not_found (@) under base as '' {
+        $ctx->response->body( 'Page Not Found' );
+    }
+}
diff --git a/t/lib/TestApp/ControllerRole/ModifierSignatures.pm b/t/lib/TestApp/ControllerRole/ModifierSignatures.pm
new file mode 100644 (file)
index 0000000..fbc2079
--- /dev/null
@@ -0,0 +1,9 @@
+use CatalystX::Declare;
+
+controller_role TestApp::ControllerRole::ModifierSignatures {
+
+    around foo (@args) {
+        $self->$orig(@args);
+        $args[0]->response->body( $args[0]->response->body . ' modified' );
+    }
+}