X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fbackcompat%2F0.04006%2Flib%2Fdbixcsl_common_tests.pm;h=c29ed4e4c211ecf5a1956fddf3873ca67cbe716f;hb=9ff235d2b5c3ae8d08097744344bce8f119e709b;hp=5dd3ba213e75ba3fad8f4055eb7966a0ec9b2a35;hpb=ee07e280e5cfc275ee3ddd376031d088188b45c2;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/backcompat/0.04006/lib/dbixcsl_common_tests.pm b/t/backcompat/0.04006/lib/dbixcsl_common_tests.pm index 5dd3ba2..c29ed4e 100644 --- a/t/backcompat/0.04006/lib/dbixcsl_common_tests.pm +++ b/t/backcompat/0.04006/lib/dbixcsl_common_tests.pm @@ -43,7 +43,7 @@ sub _monikerize { sub run_tests { my $self = shift; - plan tests => 101; + plan tests => 97; $self->create(); @@ -66,13 +66,6 @@ sub run_tests { ); $loader_opts{db_schema} = $self->{db_schema} if $self->{db_schema}; - eval { require Class::Inspector }; - if($@) { - $self->{_no_rs_components} = 1; - } - else { - $loader_opts{resultset_components} = [ qw/TestRSComponent/ ]; - } { my @loader_warnings; @@ -91,28 +84,25 @@ sub run_tests { $warn_count++ if grep /Dynamic schema detected/, @loader_warnings; $warn_count++ for grep /^Bad table or view/, @loader_warnings; - if($self->{skip_rels}) { - is(scalar(@loader_warnings), $warn_count) - or diag "Did not get the expected 0 warnings. Warnings are: " - . join('',@loader_warnings); - ok(1); - } - else { - $warn_count++; - is(scalar(@loader_warnings), $warn_count) - or diag "Did not get the expected 1 warning. Warnings are: " - . join('',@loader_warnings); - is(grep(/loader_test9 has no primary key/, @loader_warnings), 1); - } + is(scalar(@loader_warnings), $warn_count) + or diag "Did not get the expected 0 warnings. Warnings are: " + . join('',@loader_warnings); } my $conn = $schema_class->clone; my $monikers = {}; my $classes = {}; foreach my $source_name ($schema_class->sources) { - my $table_name = $schema_class->source($source_name)->from; + my $table_name = $schema_class->loader->moniker_to_table->{$source_name}; + + my $result_class = $schema_class->source($source_name)->result_class; + $monikers->{$table_name} = $source_name; - $classes->{$table_name} = $schema_class . q{::} . $source_name; + $classes->{$table_name} = $result_class; + + # some DBs (Firebird, Oracle) uppercase everything + $monikers->{lc $table_name} = $source_name; + $classes->{lc $table_name} = $result_class; } # for debugging... @@ -176,7 +166,7 @@ sub run_tests { { my ($skip_tab, $skip_tabo, $skip_taba, $skip_cmeth, - $skip_rsmeth, $skip_tcomp, $skip_trscomp); + $skip_tcomp, $skip_trscomp); can_ok( $class1, 'test_additional_base' ) or $skip_tab = 1; can_ok( $class1, 'test_additional_base_override' ) or $skip_tabo = 1; @@ -184,8 +174,6 @@ sub run_tests { can_ok( $class1, 'dbix_class_testcomponent' ) or $skip_tcomp = 1; can_ok( $class1, 'loader_test1_classmeth' ) or $skip_cmeth = 1; - can_ok( $rsobj1, 'loader_test1_rsmeth' ) or $skip_rsmeth = 1; - SKIP: { skip "Pre-requisite test failed", 1 if $skip_tab; is( $class1->test_additional_base, "test_additional_base", @@ -212,26 +200,9 @@ sub run_tests { } SKIP: { - skip "These two tests need Class::Inspector installed", 2 - if $self->{_no_rs_components}; - can_ok($rsobj1, 'dbix_class_testrscomponent') or $skip_trscomp = 1; - SKIP: { - skip "Pre-requisite test failed", 1 if $skip_trscomp; - is( $rsobj1->dbix_class_testrscomponent, - 'dbix_class_testrscomponent works' ); - } - } - - SKIP: { skip "Pre-requisite test failed", 1 if $skip_cmeth; is( $class1->loader_test1_classmeth, 'all is well' ); } - - # XXX put this back in when the TODO above works... - #SKIP: { - # skip "Pre-requisite test failed", 1 if $skip_rsmeth; - # is( $rsobj1->loader_test1_rsmeth, 'all is still well' ); - #} } @@ -465,7 +436,11 @@ sub run_tests { $obj10_2->loader_test11( $obj11->id11() ); $obj10_2->update(); }; - is($@, '', 'No errors after eval{}'); + is($@, '', 'No errors after eval{}') + or do { + diag explain $rsobj10->result_source->relationship_info('loader_test11'); + diag explain $rsobj11->result_source->relationship_info('loader_test10'); + }; SKIP: { skip 'Previous eval block failed', 3 @@ -542,18 +517,15 @@ sub run_tests { ); { - # Silence annoying but harmless postgres "NOTICE: CREATE TABLE..." - local $SIG{__WARN__} = sub { - my $msg = shift; - warn $msg unless $msg =~ m{^NOTICE:\s+CREATE TABLE}; - }; - my $dbh = $self->dbconnect(1); $dbh->do($_) for @statements_rescan; $dbh->disconnect; } - my @new = $conn->rescan; + my @new = do { + local $SIG{__WARN__} = sub {}; + $conn->rescan; + }; is(scalar(@new), 1); is($new[0], 'LoaderTest30'); @@ -576,6 +548,12 @@ sub dbconnect { AutoCommit => 1, } ); + if ($self->{dsn} =~ /^[^:]+:SQLite:/) { + $dbh->do ('PRAGMA synchronous = OFF'); + } + elsif ($self->{dsn} =~ /^[^:]+:Pg:/) { + $dbh->do ('SET client_min_messages=WARNING'); + } die "Failed to connect to database: $DBI::errstr" if !$dbh; @@ -665,7 +643,7 @@ sub create { dat VARCHAR(8), from_id INTEGER, to_id INTEGER, - PRIMARY KEY (id1,id2) + PRIMARY KEY (id1,id2), FOREIGN KEY (from_id) REFERENCES loader_test4 (id), FOREIGN KEY (to_id) REFERENCES loader_test4 (id) ) $self->{innodb} @@ -902,12 +880,6 @@ sub create { my $dbh = $self->dbconnect(1); - # Silence annoying but harmless postgres "NOTICE: CREATE TABLE..." - local $SIG{__WARN__} = sub { - my $msg = shift; - warn $msg unless $msg =~ m{^NOTICE:\s+CREATE TABLE}; - }; - $dbh->do($_) for (@statements); unless($self->{skip_rels}) { # hack for now, since DB2 doesn't like inline comments, and we need