| 1 | package Data::MuForm::Test; | ||
| 2 | # ABSTRACT: provides is_html method used in tests | ||
| 3 | 10 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 10 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 10 | ▶ | use base 'Test::Builder::Module'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 10 | ▶ | use HTML::TreeBuilder; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 10 | ▶ | use Test::Builder::Module; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 10 | our @EXPORT = ('is_html'); | |
| 9 | 10 | ▶ | use Encode ('decode'); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | |||
| 12 | sub is_html { | ||
| 13 | 45 | ▶ | my ( $got, $expected, $message ) = @_; |
|
Subroutine
is_html: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 14 | 45 | my $t1 = HTML::TreeBuilder->new; | |
| 15 | 45 | my $t2 = HTML::TreeBuilder->new; | |
| 16 | |||
| 17 | 45 | $got = decode('utf8', $got); | |
| 18 | 45 | $expected = decode('utf8', $expected); | |
| 19 | 45 | $t1->parse($got); | |
| 20 | 45 | $t1->eof; | |
| 21 | 45 | $t2->parse($expected); | |
| 22 | 45 | $t2->eof; | |
| 23 | 45 | my $out1 = $t1->as_XML; | |
| 24 | 45 | my $out2 = $t2->as_XML; | |
| 25 | 45 | $t1->delete; | |
| 26 | 45 | $t2->delete; | |
| 27 | 45 | my $tb = Data::MuForm::Test->builder; | |
| 28 | 45 | return $tb->is_eq($out1, $out2, $message); | |
| 29 | } | ||
| 30 | |||
| 31 | 10 | 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 | ||