Tests for triggers.
Ken Youens-Clark [Fri, 3 Oct 2003 23:56:54 +0000 (23:56 +0000)]
t/13schema.t

index 0d69f9b..f031ef2 100644 (file)
@@ -4,7 +4,7 @@
 $| = 1;
 
 use strict;
-use Test::More tests => 160;
+use Test::More tests => 166;
 use SQL::Translator::Schema::Constants;
 
 require_ok( 'SQL::Translator::Schema' );
@@ -462,3 +462,31 @@ require_ok( 'SQL::Translator::Schema' );
     is( $v->sql, $sql, qq[Name is "$sql"] );
     is( join(':', $v->fields), 'name:age', qq[Fields are "$fields"] );
 }
+
+#
+# Trigger
+#
+{
+    my $name                = 'foo_trigger';
+    my $perform_action_when = 'after';
+    my $database_event      = 'insert';
+    my $on_table            = 'foo';
+    my $action              = 'update modified=timestamp();';
+    my $s                   = SQL::Translator::Schema->new;
+    my $t                   = $s->add_trigger(
+        name                => $name,
+        perform_action_when => $perform_action_when,
+        database_event      => $database_event,
+        on_table            => $on_table,
+        action              => $action,
+    ) or die $s->error;
+
+    isa_ok( $t, 'SQL::Translator::Schema::Trigger', 'Trigger' );
+    is( $t->name, $name, qq[Name is "$name"] );
+    is( $t->perform_action_when, $perform_action_when, 
+        qq[Perform action when is "$perform_action_when"] );
+    is( $t->database_event, $database_event, 
+        qq[Database event is "$database_event"] );
+    is( $t->on_table, $on_table, qq[Table is "$on_table"] );
+    is( $t->action, $action, qq[Action is "$action"] );
+}