use strict;
use vars qw(%HANDLERS);
use Test::More;
+use Test::SQL::Translator qw(maybe_plan);
use SQL::Translator;
-my ($p, $tables, $classes);
-eval {
- require HTML::Parser;
- $p = HTML::Parser->new(api_version => 3);
- $p->strict_names(1);
-};
-if ($@) {
- plan skip_all => "Missing HTML::Parser";
+BEGIN {
+ maybe_plan(5,
+ 'HTML::Parser',
+ 'SQL::Translator::Parser::MySQL',
+ 'SQL::Translator::Producer::HTML');
}
+my ($p, $tables, $classes);
+$p = HTML::Parser->new(api_version => 3);
+$p->strict_names(1);
+
my $create = q|
CREATE TABLE foo (
int id PRIMARY KEY AUTO_INCREMENT NOT NULL,
|;
my $tr = SQL::Translator->new(parser => 'MySQL', producer => 'HTML');
-my $parsed = $tr->translate(data => $create);
+my $parsed = $tr->translate(data => $create) or die $tr->error;
my $status;
eval {
- $status = $p->parse($parsed);
+ $status = $p->parse($parsed);
};
if ($@) {
- plan tests => 1;
+ daig $@;
fail("Unable to parse the output!");
- exit 1;
}
-plan tests => 5;
-
# General
ok($parsed, "Parsed table OK");
ok($status, "Parsed HTML OK");
$p->handler(start => @{$HANDLERS{count_tables}});
$p->parse($parsed);
-is($tables, 2, "One table in the SQL produces 2 <table> tags");
+is($tables, 3, "One table in the SQL produces 3 <table> tags");
$tables = $classes = 0;
$p->handler(start => @{$HANDLERS{count_classes}});
$classes++;
}
}, 'tagname,attr',
- ],
+ ],
);
}