-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
59 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use strict; | ||
use warnings; | ||
use Test::More; | ||
|
||
{ | ||
package Test::Form; | ||
use HTML::FormHandler::Moose; | ||
extends 'HTML::FormHandler'; | ||
|
||
has '+name' => ( default => 'test_errors' ); | ||
has_field 'foo' => ( required => 1 ); | ||
has_field 'bar' => ( type => 'Integer' ); | ||
|
||
} | ||
|
||
my $form = Test::Form->new; | ||
$form->process( params => { bar => 'abc' } ); | ||
|
||
is( $form->num_errors, 2, 'got two errors' ); | ||
|
||
my $expected = '<form id="test_errors" method="post" > | ||
<fieldset class="main_fieldset"> | ||
<div class="error"><label class="label" for="foo">Foo: </label><input type="text" name="foo" id="foo" value="" /> | ||
<span class="error_message">Foo field is required</span></div> | ||
<div class="error"><label class="label" for="bar">Bar: </label><input type="text" name="bar" id="bar" size="8" value="abc" /> | ||
<span class="error_message">Value must be an integer</span></div> | ||
</fieldset></form>'; | ||
my $rendered = $form->render; | ||
|
||
SKIP: { | ||
skip 'Install HTML::TreeBuilder to test TT Result', 3 | ||
unless eval { require HTML::TreeBuilder && $HTML::TreeBuilder::VERSION >= 3.23 }; | ||
my $exp_tree = HTML::TreeBuilder->new_from_content($expected); | ||
my $got_tree = HTML::TreeBuilder->new_from_content($rendered); | ||
is($exp_tree->as_HTML, $got_tree->as_HTML, 'error rendering matches expected'); | ||
} | ||
|
||
done_testing; |