]> git.imager.perl.org - bse.git/commitdiff
trivial test for BSE::UserReg
authorTony Cook <tony@develop-help.com>
Mon, 5 Nov 2012 08:41:34 +0000 (19:41 +1100)
committerTony Cook <tony@develop-help.com>
Mon, 5 Nov 2012 08:41:34 +0000 (19:41 +1100)
MANIFEST
t/070-user/050-user.t [new file with mode: 0644]
t/BSE/Test.pm

index 06a00592c5b0b6616fee156c7904fb011ce439dc..7e16e05aebeadcf4a5b06cfec7438b98b0f8908a 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -870,6 +870,7 @@ t/060-generate/020-catalog.t
 t/060-generate/030-thumb.t
 t/070-user/010-edit.t
 t/070-user/020-images.t
+t/070-user/050-user.t
 t/080-remote/010-save.t
 t/080-remote/020-cat.t
 t/080-remote/030-parent.t
diff --git a/t/070-user/050-user.t b/t/070-user/050-user.t
new file mode 100644 (file)
index 0000000..4258624
--- /dev/null
@@ -0,0 +1,16 @@
+#!perl -w
+use strict;
+use BSE::Test qw(make_ua base_url test_actions);
+use Test::More tests => 2;
+use Carp "confess";
+use File::Spec;
+
+$SIG{__DIE__} = sub { confess @_ };
+
+BEGIN {
+  unshift @INC, File::Spec->catdir(BSE::Test::base_dir(), "cgi-bin", "modules");
+}
+
+require_ok("BSE::UserReg");
+
+test_actions("BSE::UserReg");
\ No newline at end of file
index 45c6efd2fb0c9350ac994ca93683def5e4d2ff29..0d916c38d225e043b1797739a0ed5c832c6f5a5f 100644 (file)
@@ -6,7 +6,7 @@ require 'Exporter.pm';
 @EXPORT = qw(base_url ok fetch_ok make_url skip make_ua);
 @EXPORT_OK = qw(base_url ok make_ua fetch_url fetch_ok make_url skip 
                 make_post check_form post_ok check_content follow_ok
-                follow_refresh_ok click_ok config);
+                follow_refresh_ok click_ok config test_actions);
 
 my %conf;
 
@@ -402,5 +402,26 @@ sub check_form {
   return %values;
 }
 
+# test that all actions have methods for a given dispatcher class
+sub test_actions {
+  my ($class) = @_;
+
+  my $tb = Test::Builder->new;
+
+  my $obj = $class->new;
+  my $actions = $obj->actions;
+  my @bad;
+  for my $action (sort keys %$actions) {
+    my $method = "req_$action";
+    unless ($obj->can($method)) {
+      push @bad, $action;
+    }
+  }
+  $tb->ok(!@bad, "check all actions have a method for $class");
+  print STDERR "No method found for $class action $_\n" for @bad;
+
+  return !@bad;
+}
+
 1;