From 674cdd6697c307087f4efb85cc7613c2b3cebd81 Mon Sep 17 00:00:00 2001 From: Terrence Brannon Date: Mon, 16 Mar 2009 16:11:23 -0400 Subject: [PATCH] fillinform tests --- lib/HTML/Element/Library.pm | 2 ++ t/fillinform.t | 29 ++++++++++++++++++++++++++++ t/html/fillinform/fillinform.exp | 23 ++++++++++++++++++++++ t/html/fillinform/fillinform.gen | 23 ++++++++++++++++++++++ t/html/fillinform/fillinform.initial | 21 ++++++++++++++++++++ 5 files changed, 98 insertions(+) create mode 100644 t/fillinform.t create mode 100644 t/html/fillinform/fillinform.exp create mode 100644 t/html/fillinform/fillinform.gen create mode 100644 t/html/fillinform/fillinform.initial diff --git a/lib/HTML/Element/Library.pm b/lib/HTML/Element/Library.pm index df9681f..bc85c9d 100644 --- a/lib/HTML/Element/Library.pm +++ b/lib/HTML/Element/Library.pm @@ -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 index 0000000..3a6c0f2 --- /dev/null +++ b/t/fillinform.t @@ -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 index 0000000..ed123ac --- /dev/null +++ b/t/html/fillinform/fillinform.exp @@ -0,0 +1,23 @@ + + + +
+

Dialer

+
+
City: + +
+
State: + +
+
Company: + +
+
Data Source: + +
+ +
+
+ + diff --git a/t/html/fillinform/fillinform.gen b/t/html/fillinform/fillinform.gen new file mode 100644 index 0000000..ed123ac --- /dev/null +++ b/t/html/fillinform/fillinform.gen @@ -0,0 +1,23 @@ + + + +
+

Dialer

+
+
City: + +
+
State: + +
+
Company: + +
+
Data Source: + +
+ +
+
+ + diff --git a/t/html/fillinform/fillinform.initial b/t/html/fillinform/fillinform.initial new file mode 100644 index 0000000..d0269d9 --- /dev/null +++ b/t/html/fillinform/fillinform.initial @@ -0,0 +1,21 @@ +
+

Dialer

+ +
+
+ City: +
+ +
+ State: +
+ +
+ Company: +
+ +
+ Data Source: +
+
+
-- 2.30.2