From: Terrence Brannon Date: Mon, 16 Mar 2009 20:11:23 +0000 (-0400) Subject: fillinform tests X-Git-Tag: 5.200_001~35 X-Git-Url: http://git.ieval.ro/?p=html-element-library.git;a=commitdiff_plain;h=674cdd6697c307087f4efb85cc7613c2b3cebd81 fillinform tests --- 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: +
+
+