Extra data and first test for xml database_event support
Peter Rabbitson [Sun, 3 May 2009 01:27:29 +0000 (01:27 +0000)]
t/16xml-parser.t
t/data/xml/schema.xml

index 19c6111..485d3e6 100644 (file)
@@ -27,7 +27,7 @@ use constant DEBUG => (exists $opt{d} ? 1 : 0);
 #=============================================================================
 
 BEGIN {
-    maybe_plan(204, 'SQL::Translator::Parser::XML::SQLFairy');
+    maybe_plan(212, 'SQL::Translator::Parser::XML::SQLFairy');
 }
 
 my $testschema = "$Bin/data/xml/schema.xml";
@@ -39,12 +39,21 @@ $sqlt = SQL::Translator->new(
     add_drop_table => 1,
 );
 die "Can't find test schema $testschema" unless -e $testschema;
-my $sql = $sqlt->translate(
+
+my $sql;
+{
+  my @w;
+  local $SIG{__WARN__} = sub { push @w, $_[0] if $_[0] =~ /The database_event tag is deprecated - please use database_events/ };
+
+  $sql = $sqlt->translate(
     from     => 'XML-SQLFairy',
     to       => 'MySQL',
     filename => $testschema,
-) or die $sqlt->error;
-print $sql if DEBUG;
+  ) or die $sqlt->error;
+  print $sql if DEBUG;
+
+  ok (@w, 'database_event deprecation warning issued');
+}
 
 # Test the schema objs generted from the XML
 #
@@ -220,6 +229,16 @@ schema_ok( $scma, {
                 bar => "baz",
             },
         },
+        {
+            name                => 'bar_trigger',
+            perform_action_when => 'before',
+            database_events     => 'insert,update',
+            on_table            => 'Basic',
+            action              => 'update modified2=timestamp();',
+            extra => {
+                hello => "aliens",
+            },
+        },
     ],
 
     procedures => [
index b750a5d..02e2877 100644 (file)
@@ -92,11 +92,16 @@ Created on Fri Aug 15 15:08:18 2003
   </views>
 
   <triggers>
-      <trigger name="foo_trigger" database_events="insert" on_table="Basic"
+      <trigger name="foo_trigger" database_event="insert" on_table="Basic"
           perform_action_when="after" order="1">
           <action>update modified=timestamp();</action>
           <extra foo="bar" hello="world" bar="baz" />
       </trigger>
+      <trigger name="bar_trigger" database_events="insert , update" on_table="Basic"
+          perform_action_when="before" order="1">
+          <action>update modified2=timestamp();</action>
+          <extra hello="aliens" />
+      </trigger>
   </triggers>
 
   <procedures>