line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormHandler::Test; |
2
|
|
|
|
|
|
|
# ABSTRACT: provides is_html method used in tests |
3
|
|
|
|
|
|
|
$HTML::FormHandler::Test::VERSION = '0.40067'; |
4
|
56
|
|
|
56
|
|
2819741
|
use strict; |
|
56
|
|
|
|
|
86
|
|
|
56
|
|
|
|
|
1405
|
|
5
|
56
|
|
|
56
|
|
189
|
use warnings; |
|
56
|
|
|
|
|
70
|
|
|
56
|
|
|
|
|
1279
|
|
6
|
56
|
|
|
56
|
|
177
|
use base 'Test::Builder::Module'; |
|
56
|
|
|
|
|
60
|
|
|
56
|
|
|
|
|
4914
|
|
7
|
56
|
|
|
56
|
|
32525
|
use HTML::TreeBuilder; |
|
56
|
|
|
|
|
1251984
|
|
|
56
|
|
|
|
|
513
|
|
8
|
56
|
|
|
56
|
|
2052
|
use Test::Builder::Module; |
|
56
|
|
|
|
|
90
|
|
|
56
|
|
|
|
|
521
|
|
9
|
|
|
|
|
|
|
our @EXPORT = ('is_html'); |
10
|
56
|
|
|
56
|
|
33876
|
use Encode ('decode'); |
|
56
|
|
|
|
|
423811
|
|
|
56
|
|
|
|
|
9106
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub is_html { |
14
|
189
|
|
|
189
|
0
|
4863
|
my ( $got, $expected, $message ) = @_; |
15
|
189
|
|
|
|
|
1130
|
my $t1 = HTML::TreeBuilder->new; |
16
|
189
|
|
|
|
|
36945
|
my $t2 = HTML::TreeBuilder->new; |
17
|
|
|
|
|
|
|
|
18
|
189
|
|
|
|
|
22104
|
$got = decode('utf8', $got); |
19
|
189
|
|
|
|
|
8215
|
$expected = decode('utf8', $expected); |
20
|
189
|
|
|
|
|
6256
|
$t1->parse($got); |
21
|
189
|
|
|
|
|
297114
|
$t1->eof; |
22
|
189
|
|
|
|
|
27872
|
$t2->parse($expected); |
23
|
189
|
|
|
|
|
279399
|
$t2->eof; |
24
|
189
|
|
|
|
|
23244
|
my $out1 = $t1->as_XML; |
25
|
189
|
|
|
|
|
216813
|
my $out2 = $t2->as_XML; |
26
|
189
|
|
|
|
|
194379
|
$t1->delete; |
27
|
189
|
|
|
|
|
16969
|
$t2->delete; |
28
|
189
|
|
|
|
|
14014
|
my $tb = HTML::FormHandler::Test->builder; |
29
|
189
|
|
|
|
|
2481
|
return $tb->is_eq($out1, $out2, $message); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__END__ |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=pod |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=encoding UTF-8 |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
HTML::FormHandler::Test - provides is_html method used in tests |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 VERSION |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
version 0.40067 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SYNOPSIS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Simple 'is_html' method for testing form rendering against |
51
|
|
|
|
|
|
|
an expected value without having to fuss with exactly matching |
52
|
|
|
|
|
|
|
newlines and spaces. Uses L<HTML::TreeBuilder>, which uses |
53
|
|
|
|
|
|
|
L<HTML::Parser>. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
See numerous examples in the 't/render' directory. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
use Test::More; |
58
|
|
|
|
|
|
|
use HTML::FormHandler::Test; |
59
|
|
|
|
|
|
|
use_ok('MyApp::Form::Basic'); |
60
|
|
|
|
|
|
|
my $form = MyApp::Form::Basic->new; |
61
|
|
|
|
|
|
|
$form->process; |
62
|
|
|
|
|
|
|
my $expected = '<form html>'; |
63
|
|
|
|
|
|
|
is_html( $form->render, $expected, 'form renders ok' ); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
FormHandler Contributors - see HTML::FormHandler |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Gerda Shank. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
74
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |