Release commit for 1.62
[dbsrgits/SQL-Translator.git] / t / 29html.t
index cb6a0fe..04fb30c 100644 (file)
@@ -9,19 +9,21 @@
 use strict;
 use vars qw(%HANDLERS);
 use Test::More;
+use Test::SQL::Translator qw(maybe_plan);
 use SQL::Translator;
-use Data::Dump qw(dump);
 
-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,
+        'CGI',
+        '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,
@@ -30,20 +32,17 @@ CREATE TABLE foo (
 |;
 
 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");
@@ -51,7 +50,7 @@ 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}});
@@ -96,6 +95,6 @@ BEGIN {
                     $classes++;
                 }
             }, 'tagname,attr',
-        ], 
+        ],
     );
 }