more and a bit better organized tests
Robert 'phaylon' Sedlacek [Fri, 31 Jul 2009 18:33:59 +0000 (20:33 +0200)]
Makefile.PL
lib/CatalystX/Declare/Keyword/Application.pm
t/010_application.t [new file with mode: 0644]
t/020_controller_roles.t [new file with mode: 0644]
t/030_controllers.t [new file with mode: 0644]
t/050_controller_composition.t [new file with mode: 0644]
t/100_complex.t [moved from t/001_basic.t with 98% similarity]
t/lib/Catalyst/Plugin/CatalystX/Declare/TestPlugin.pm [new file with mode: 0644]
t/lib/TestApp.pm
t/lib/TestApp/Controller/Composed.pm [new file with mode: 0644]
t/lib/TestApp/Controller/TestController.pm [new file with mode: 0644]

index 7d673a3..0e9e0b3 100644 (file)
@@ -23,7 +23,7 @@ requires        'MooseX::Types',            '0.16';
 
 test_requires   'Catalyst::Test';
 test_requires   'FindBin';
-test_requires   'Test::More',               '0.86';
+test_requires   'Test::More',               '0.92';
 
 repository      'http://github.com/phaylon/catalystx-declarative/tree/master';
 bugtracker      'http://github.com/phaylon/catalystx-declarative/issues';
index 698fd95..dd3006e 100644 (file)
@@ -56,8 +56,7 @@ Catalyst's C<setup> method. This hijacking is proably going away someday since
 in the future plugins will be actual roles.
 
 You don't have to call the C<setup> method yourself, this will be done by the
-handler after the body has been run. If you need to run code specifically before
-or after the C<setup> method has been run, you can always use method modifiers.
+handler after the body has been run.
 
 =head1 SUPERCLASSES
 
diff --git a/t/010_application.t b/t/010_application.t
new file mode 100644 (file)
index 0000000..b0bf997
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More;
+
+use Catalyst::Test 'TestApp';
+
+is(TestApp->config->{name}, 'CatalystX::Declare TestApp', 'config setting via $CLASS');
+is(TestApp->ctx_method(23), 23, 'calling context method');
+is(TestApp->cx_declare_test_plugin_method, 'plugin', 'plugin is available');
+
+done_testing;
diff --git a/t/020_controller_roles.t b/t/020_controller_roles.t
new file mode 100644 (file)
index 0000000..e8f42f5
--- /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 aliased 'TestApp::TestRole';
+
+ok +(my $meta = TestRole->meta), 'controller role has meta';
+
+ok $meta->has_method('something_from_the_role'), 'method is available in role';
+ok $meta->has_method('action_from_ctrl_role'), 'action method is available in role';
+
+done_testing;
diff --git a/t/030_controllers.t b/t/030_controllers.t
new file mode 100644 (file)
index 0000000..1aa7a60
--- /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 aliased 'TestApp::Controller::TestController';
+
+ok +(my $meta = TestController->meta), 'controller has meta';
+
+ok $meta->has_method('ctrl_method'), 'method is available in controller';
+ok $meta->has_method('ctrl_action'), 'action method is available in controller';
+
+done_testing;
diff --git a/t/050_controller_composition.t b/t/050_controller_composition.t
new file mode 100644 (file)
index 0000000..19e3e5f
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More;
+
+use aliased 'TestApp::Controller::Composed';
+
+ok +(my $meta = Composed->meta), 'controller has meta';
+
+ok $meta->find_method_by_name($_), "method $_ is available in composed controller"
+    for qw(
+            original_method
+            original_action
+            inherited_method
+            inherited_action
+            composed_method
+            composed_action
+        );
+
+done_testing;
similarity index 98%
rename from t/001_basic.t
rename to t/100_complex.t
index 8c611d1..28e8cf8 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 use FindBin;
 use lib "$FindBin::Bin/lib";
 
-use Test::More tests => 21;
+use Test::More; 
 use Catalyst::Test 'TestApp';
 
 # simple stuff
@@ -60,3 +60,6 @@ is get('/foo/surrounded_target'), 'foo/surrounded_target surrounded', 'action wa
 
 # inline classes
 is get('/foo/inline_class'), 'HELLO', 'inline classes work as expected';
+
+
+done_testing;
diff --git a/t/lib/Catalyst/Plugin/CatalystX/Declare/TestPlugin.pm b/t/lib/Catalyst/Plugin/CatalystX/Declare/TestPlugin.pm
new file mode 100644 (file)
index 0000000..a270f6a
--- /dev/null
@@ -0,0 +1,7 @@
+package Catalyst::Plugin::CatalystX::Declare::TestPlugin;
+use strict;
+use warnings;
+
+sub cx_declare_test_plugin_method { 'plugin' }
+
+1;
index d2942ab..54e7b8c 100644 (file)
@@ -1,7 +1,9 @@
 use CatalystX::Declare;
 
-application TestApp with Static::Simple {
+application TestApp with CatalystX::Declare::TestPlugin {
 
     $CLASS->config(name => 'CatalystX::Declare TestApp');
+
+    method ctx_method (ClassName $app: $arg) { $arg }
 }
 
diff --git a/t/lib/TestApp/Controller/Composed.pm b/t/lib/TestApp/Controller/Composed.pm
new file mode 100644 (file)
index 0000000..167a91e
--- /dev/null
@@ -0,0 +1,19 @@
+use CatalystX::Declare;
+
+controller_role TestApp::ControllerRole::Composed {
+    method composed_method { }
+    action composed_action;
+}
+
+controller TestApp::ControllerBase::Composed {
+    method inherited_method { }
+    action inherited_action;
+}
+
+controller TestApp::Controller::Composed
+    extends TestApp::ControllerBase::Composed
+    with    TestApp::ControllerRole::Composed {
+
+    method original_method { }
+    action original_action;
+}
diff --git a/t/lib/TestApp/Controller/TestController.pm b/t/lib/TestApp/Controller/TestController.pm
new file mode 100644 (file)
index 0000000..445ce6f
--- /dev/null
@@ -0,0 +1,8 @@
+use CatalystX::Declare;
+
+controller TestApp::Controller::TestController {
+
+    method ctrl_method { }
+
+    action ctrl_action;
+}