FormHandler/Test.pm

filter: Statementstmt 100% 36 / 36 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 97.7% 43 / 44 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« FormHandler/Field/Integer.pm ↑ Summary FormHandler/Field/DateMDY.pm »
1 package HTML::FormHandler::Test;
2 # ABSTRACT: provides is_html method used in tests
3 59 $HTML::FormHandler::Test::VERSION = '0.410001';
4 59 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 59 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 59 ▶use base 'Test::Builder::Module';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 59 ▶use HTML::TreeBuilder;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 59 ▶use Test::Builder::Module;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 59 our @EXPORT = ('is_html');
10 59 ▶use Encode ('decode');
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 sub is_html {
14 193 ▶ my ( $got, $expected, $message ) = @_;
Subroutine is_html: called CC=1 SCAR=0.0
Pod undocumented
15 193 my $t1 = HTML::TreeBuilder->new;
16 193 my $t2 = HTML::TreeBuilder->new;
17  
18 193 $got = decode('utf8', $got);
19 193 $expected = decode('utf8', $expected);
20 193 $t1->parse($got);
21 193 $t1->eof;
22 193 $t2->parse($expected);
23 193 $t2->eof;
24 193 my $out1 = $t1->as_XML;
25 193 my $out2 = $t2->as_XML;
26 193 $t1->delete;
27 193 $t2->delete;
28 193 my $tb = HTML::FormHandler::Test->builder;
29 193 return $tb->is_eq($out1, $out2, $message);
30 }
31  
32 59 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.410001
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) 2017 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
« FormHandler/Field/Integer.pm ↑ Summary FormHandler/Field/DateMDY.pm »