File Coverage

blib/lib/Data/MuForm/Test.pm
Criterion Covered Total %
statement 33 33 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 40 41 97.5


line stmt bran cond sub pod time code
1             package Data::MuForm::Test;
2             # ABSTRACT: provides is_html method used in tests
3 10     10   468652 use strict;
  10         13  
  10         230  
4 10     10   33 use warnings;
  10         11  
  10         250  
5 10     10   29 use base 'Test::Builder::Module';
  10         10  
  10         889  
6 10     10   6391 use HTML::TreeBuilder;
  10         216844  
  10         83  
7 10     10   353 use Test::Builder::Module;
  10         13  
  10         92  
8             our @EXPORT = ('is_html');
9 10     10   5908 use Encode ('decode');
  10         71312  
  10         1462  
10              
11              
12             sub is_html {
13 45     45 0 234 my ( $got, $expected, $message ) = @_;
14 45         204 my $t1 = HTML::TreeBuilder->new;
15 45         7573 my $t2 = HTML::TreeBuilder->new;
16              
17 45         5418 $got = decode('utf8', $got);
18 45         1325 $expected = decode('utf8', $expected);
19 45         1274 $t1->parse($got);
20 45         39622 $t1->eof;
21 45         5285 $t2->parse($expected);
22 45         38145 $t2->eof;
23 45         5571 my $out1 = $t1->as_XML;
24 45         37186 my $out2 = $t2->as_XML;
25 45         34419 $t1->delete;
26 45         2859 $t2->delete;
27 45         2358 my $tb = Data::MuForm::Test->builder;
28 45         479 return $tb->is_eq($out1, $out2, $message);
29             }
30              
31             1;
32              
33             __END__
34              
35             =pod
36              
37             =encoding UTF-8
38              
39             =head1 NAME
40              
41             Data::MuForm::Test - provides is_html method used in tests
42              
43             =head1 VERSION
44              
45             version 0.04
46              
47             =head1 SYNOPSIS
48              
49             Simple 'is_html' method for testing form rendering against
50             an expected value without having to fuss with exactly matching
51             newlines and spaces. Uses L<HTML::TreeBuilder>, which uses
52             L<HTML::Parser>.
53              
54             =head1 AUTHOR
55              
56             Gerda Shank
57              
58             =head1 COPYRIGHT AND LICENSE
59              
60             This software is copyright (c) 2017 by Gerda Shank.
61              
62             This is free software; you can redistribute it and/or modify it under
63             the same terms as the Perl 5 programming language system itself.
64              
65             =cut