X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F13schema.t;h=497ea751930c126fb08e7df2f290b8a133e780c0;hb=f24e48939a15ba970f17440b616c078b093db945;hp=993e391daa28504bef8951fa097e500edfed5624;hpb=97568176bd32bb3ded3aa530f2092ca8f4f45df2;p=dbsrgits%2FSQL-Translator-2.0-ish.git diff --git a/t/13schema.t b/t/13schema.t index 993e391..497ea75 100644 --- a/t/13schema.t +++ b/t/13schema.t @@ -108,8 +108,9 @@ require_ok( 'SQL::Translator::Object::View' ); my $person_table = SQL::Translator::Object::Table->new({ name => 'person', schema => $schema, + comments => 'foo', }); - $person_table->comments('foo'); + $schema->add_table($person_table); is( $person_table->name, 'person', 'Table name is "person"' ); is( $person_table->is_valid, undef, 'Table is not yet valid' ); @@ -120,7 +121,7 @@ require_ok( 'SQL::Translator::Object::View' ); # # Field default new # - my $person_table_column = SQL::Translator::Object::Column->new( name => 'foo' ); + my $person_table_column = SQL::Translator::Object::Column->new( name => 'foo', extra => { foo => 'bar', baz => 'quux' } ); my $f1 = $person_table->add_column($person_table_column); isa_ok( $f1, 'SQL::Translator::Object::Column', 'Column' ); is( $f1->name, 'foo', 'Field name is "foo"' ); @@ -201,9 +202,8 @@ require_ok( 'SQL::Translator::Object::View' ); is( $f1->data_type('varchar'), 'varchar', 'Field data type is "varchar"' ); is( $f1->size('30'), '30', 'Field size is "30"' ); is( $f1->is_primary_key(0), '0', 'Field is_primary_key is negative' ); + $person_table->add_field( $f1 ); - $f1->extra({ foo => 'bar' }); - $f1->extra({ baz => 'quux' }); my %extra = $f1->extra; is( $extra{'foo'}, 'bar', 'Field extra "foo" is "bar"' ); is( $extra{'baz'}, 'quux', 'Field extra "baz" is "quux"' ); @@ -529,7 +529,7 @@ TODO: { # is( $t->primary_key('person_id'), undef, # q[Can't make PK on "person_id"...] ); # like( $t->error, qr/invalid field/i, "...because it doesn't exist" ); - dies_ok( sub { $t->primary_key }, "...because it doesn't exist" ); + dies_ok( sub { $t->primary_key('person_id') }, "...because it doesn't exist" ); $t->add_field({ name => 'person_id' }); my $c = $t->primary_key('person_id'); @@ -564,8 +564,9 @@ TODO: { fields => 'person_id', reference_table => 'person', table => $t1, - reference_fields => 'id', +# reference_fields => 'id', }); + $c2->add_reference_column($t1->get_column('id')); is( join('', $c2->reference_fields), 'id', 'FK found PK "person.id"' ); } @@ -586,8 +587,8 @@ TODO: { schema => $s, }); -# $v->add_field({ name => 'name' }); -# $v->add_field({ name => 'age' }); + $v->add_column({ name => 'name' }); + $v->add_column({ name => 'age' }); isa_ok( $v, 'SQL::Translator::Object::View', 'View' ); isa_ok( $v->schema, 'SQL::Translator::Object::Schema', 'Schema' ); @@ -668,7 +669,7 @@ TODO: { "Database events are [qw/insert update/] " ); - isa_ok($t2->database_events,'ARRAY','Database events'); + #isa_ok($t2->database_events,'ARRAY','Database events'); # # Trigger equal tests @@ -721,14 +722,14 @@ TODO: { comments => $comments, }); # or die $s->error; $p->parameters([ qw/foo bar/ ]); - $p->comments($comments); isa_ok( $p, 'SQL::Translator::Object::Procedure', 'Procedure' ); isa_ok( $p->schema, 'SQL::Translator::Object::Schema', 'Schema' ); is( $p->schema->name, 'ProcTest', qq[Schema name is "'ProcTest'"] ); is( $p->name, $name, qq[Name is "$name"] ); is( $p->sql, $sql, qq[SQL is "$sql"] ); - is( join(',', $p->parameters), 'foo,bar', qq[Params = 'foo,bar'] ); + + is_deeply( $p->parameters, [ qw/foo bar/ ], qq[Params = 'foo,bar'] ); is( $p->comments, $comments, qq[Comments = "$comments"] ); my @procs = $s->get_procedures;