4 # Before `make install' is performed this script should be runnable with
5 # `make test'. After `make install' it should work as `perl test.pl'
8 # Tests the visibility arg.
15 # run test with -d for debug
17 BEGIN { map { $opt{$_}=1 if s/^-// } @ARGV; }
18 use constant DEBUG => (exists $opt{d} ? 1 : 0);
22 use Test::SQL::Translator qw(maybe_plan);
24 use SQL::Translator::Schema::Constants;
28 'SQL::Translator::Parser::XML::XMI',
29 'SQL::Translator::Producer::MySQL');
31 my $testschema = "$Bin/data/xmi/Foo.poseidon2.xmi";
32 die "Can't find test schema $testschema" unless -e $testschema;
35 "" => [qw/Foo PrivateFoo Recording CD Track ProtectedFoo/],
36 [qw/fooid name protectedname privatename/],
37 "public" => [qw/Foo Recording CD Track/],
39 "protected" => [qw/Foo Recording CD Track ProtectedFoo/],
40 [qw/fooid name protectedname/],
41 "private" => [qw/Foo PrivateFoo Recording CD Track ProtectedFoo/],
42 [qw/fooid name protectedname privatename/],
44 while ( my ($vis,$tables,$foofields) = splice @testd,0,3 ) {
46 $obj = SQL::Translator->new(
47 filename => $testschema,
56 my $sql = $obj->translate;
58 my $scma = $obj->schema;
61 my @tblnames = map {$_->name} $scma->get_tables;
62 is_deeply( \@tblnames, $tables, "Tables with visibility => '$vis'");
64 # Fields from attributes
65 my @fldnames = map {$_->name} $scma->get_table("Foo")->get_fields;
66 is_deeply( \@fldnames, $foofields, "Foo fields with visibility => '$vis'");