fillinform tests
authorTerrence Brannon <TBrannon@SmartFinancial.com>
Mon, 16 Mar 2009 20:11:23 +0000 (16:11 -0400)
committerTerrence Brannon <TBrannon@SmartFinancial.com>
Mon, 16 Mar 2009 20:11:23 +0000 (16:11 -0400)
lib/HTML/Element/Library.pm
t/fillinform.t [new file with mode: 0644]
t/html/fillinform/fillinform.exp [new file with mode: 0644]
t/html/fillinform/fillinform.gen [new file with mode: 0644]
t/html/fillinform/fillinform.initial [new file with mode: 0644]

index df9681f9d73b269e40d0ca65be585f931139f1b7..bc85c9dca1598691f6d5ec2b9ec6f125fcdeb1ea 100644 (file)
@@ -36,6 +36,8 @@ sub HTML::Element::fillinform {
 
     my ($tree, $hashref)=@_;
 
+    (ref $hashref) eq 'HASH' or die 'hashref not supplied as argument' ;
+
     use HTML::FillInForm;
     my $html = $tree->as_HTML;
     my $new_html = HTML::FillInForm->fill(\$html, $hashref);
diff --git a/t/fillinform.t b/t/fillinform.t
new file mode 100644 (file)
index 0000000..3a6c0f2
--- /dev/null
@@ -0,0 +1,29 @@
+# This might look like shell script, but it's actually -*- perl -*-
+use strict;use warnings;
+use lib qw(t/ t/m/);
+
+use File::Slurp;
+use Test::More qw(no_plan);
+
+use TestUtils;
+use HTML::TreeBuilder;
+use HTML::Element::Library;
+
+sub tage {
+
+  my $root = "t/html/fillinform/fillinform";
+
+  my $tree = HTML::TreeBuilder->new_from_file("$root.initial")->guts;
+
+  my %data = (state => 'catatonic');
+
+  my $new_tree = HTML::TreeBuilder->new_from_content( $tree->fillinform(\%data) ) ;
+
+  my $generated_html = ptree($new_tree, "$root.gen");
+
+  is ($generated_html, File::Slurp::read_file("$root.exp"), "HTML for fillinform");
+}
+
+
+tage();
+
diff --git a/t/html/fillinform/fillinform.exp b/t/html/fillinform/fillinform.exp
new file mode 100644 (file)
index 0000000..ed123ac
--- /dev/null
@@ -0,0 +1,23 @@
+<html>
+  <head></head>
+  <body>
+    <div>
+      <h1>Dialer</h1>
+      <form name="appform" id="appform" method="post">
+        <div id="city_div"> City:
+          <input /="/" name="city" type="text">
+        </div>
+        <div id="state_div"> State:
+          <input /="/" value="catatonic" name="state" type="text">
+        </div>
+        <div id="company_div"> Company:
+          <input /="/" name="company" type="text">
+        </div>
+        <div id="data_source_div"> Data Source:
+          <input /="/" name="data_source" type="text">
+        </div>
+        <input /="/" value="locate records" type="submit">
+      </form>
+    </div>
+  </body>
+</html>
diff --git a/t/html/fillinform/fillinform.gen b/t/html/fillinform/fillinform.gen
new file mode 100644 (file)
index 0000000..ed123ac
--- /dev/null
@@ -0,0 +1,23 @@
+<html>
+  <head></head>
+  <body>
+    <div>
+      <h1>Dialer</h1>
+      <form name="appform" id="appform" method="post">
+        <div id="city_div"> City:
+          <input /="/" name="city" type="text">
+        </div>
+        <div id="state_div"> State:
+          <input /="/" value="catatonic" name="state" type="text">
+        </div>
+        <div id="company_div"> Company:
+          <input /="/" name="company" type="text">
+        </div>
+        <div id="data_source_div"> Data Source:
+          <input /="/" name="data_source" type="text">
+        </div>
+        <input /="/" value="locate records" type="submit">
+      </form>
+    </div>
+  </body>
+</html>
diff --git a/t/html/fillinform/fillinform.initial b/t/html/fillinform/fillinform.initial
new file mode 100644 (file)
index 0000000..d0269d9
--- /dev/null
@@ -0,0 +1,21 @@
+  <div>
+    <h1>Dialer</h1>
+
+    <form id="appform" method="post" name="appform">
+      <div id="city_div">
+        City: <input type="text" name="city">
+      </div>
+
+      <div id="state_div">
+        State: <input type="text" name="state">
+      </div>
+
+      <div id="company_div">
+        Company: <input type="text" name="company">
+      </div>
+
+      <div id="data_source_div">
+        Data Source: <input type="text" name="data_source">
+      </div><input type="submit" value="locate records">
+    </form>
+  </div>
This page took 0.013575 seconds and 4 git commands to generate.