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   505816 use strict;
  10         14  
  10         262  
4 10     10   31 use warnings;
  10         11  
  10         226  
5 10     10   32 use base 'Test::Builder::Module';
  10         11  
  10         850  
6 10     10   6589 use HTML::TreeBuilder;
  10         229026  
  10         109  
7 10     10   381 use Test::Builder::Module;
  10         14  
  10         99  
8             our @EXPORT = ('is_html');
9 10     10   6333 use Encode ('decode');
  10         72093  
  10         1585  
10              
11              
12             sub is_html {
13 45     45 0 376 my ( $got, $expected, $message ) = @_;
14 45         214 my $t1 = HTML::TreeBuilder->new;
15 45         7902 my $t2 = HTML::TreeBuilder->new;
16              
17 45         5377 $got = decode('utf8', $got);
18 45         1458 $expected = decode('utf8', $expected);
19 45         1267 $t1->parse($got);
20 45         40755 $t1->eof;
21 45         5528 $t2->parse($expected);
22 45         38635 $t2->eof;
23 45         5312 my $out1 = $t1->as_XML;
24 45         38537 my $out2 = $t2->as_XML;
25 45         33340 $t1->delete;
26 45         2985 $t2->delete;
27 45         2398 my $tb = Data::MuForm::Test->builder;
28 45         512 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.03
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