File: 691-output-html-get-sql.t

package info (click to toggle)
libparse-dia-sql-perl 0.31-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 924 kB
  • sloc: perl: 3,865; makefile: 2
file content (62 lines) | stat: -rw-r--r-- 1,521 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#   $Id:  $

use warnings;
use strict;

use Data::Dumper;
use Test::More;
use Test::Exception;
use File::Spec::Functions;
use HTML::Lint;
use lib catdir qw ( blib lib );

plan tests => 8;

diag 'HTML support is experimental';

use lib q{lib};
use_ok ('Parse::Dia::SQL');
use_ok ('Parse::Dia::SQL::Output');
use_ok ('Parse::Dia::SQL::Output::HTML');

my $diasql =
  Parse::Dia::SQL->new(file => catfile(qw(t data TestERD.dia)), db => 'html');
isa_ok($diasql, q{Parse::Dia::SQL}, q{Expect a Parse::Dia::SQL object});
can_ok($diasql, q{get_sql});

my $sql = $diasql->get_sql();
# diag($sql);

isa_ok(
  $diasql->get_output_instance(),
  q{Parse::Dia::SQL::Output::HTML},
  q{Expect Parse::Dia::SQL::Output::HTML to be used as back-end}
);

# Replace   with   (because the latter is valid XML, while
# the former isn't - even though it's fine as HTML)
my $xml = $sql;
$xml =~ s/ / /gi;

# Check the XML with XML::DOM::Parser
my $parser = new XML::DOM::Parser;
eval { my $doc = $parser->parse($xml); };
($@)
  ? fail("Failed test using XML::DOM::Parser - invalid XML")
  : pass("Passed test using XML::DOM::Parser - valid XML");

# Check the HTML with HTML::Lint
my $lint = HTML::Lint->new;
$lint->parse( $sql );
$lint->eof();
my $error_count = $lint->errors;
($error_count > 0)
  ? fail("Failed test using HTML::Lint - invalid HTML")
  : pass("Passed test using HTML::Lint - valid HTML");

# Print each error message
foreach my $error ($lint->errors) {
  diag(q{HTML-Lint: } . Dumper($error));
}

__END__