From: Ken Youens-Clark Date: Fri, 3 Oct 2003 23:56:54 +0000 (+0000) Subject: Tests for triggers. X-Git-Tag: v0.04~135 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=90fd4bf5788e22b5cd7514579bb5cc0cc638fb13;p=dbsrgits%2FSQL-Translator.git Tests for triggers. --- diff --git a/t/13schema.t b/t/13schema.t index 0d69f9b..f031ef2 100644 --- a/t/13schema.t +++ b/t/13schema.t @@ -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"] ); +}