X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F20invocations.t;h=72054e3509a2179634e1855b34a67dfb8d88e2d5;hb=462914a7047b5a165395c0f583f2d09ee317e3e2;hp=51332f8454b045fa5cae0f84f8143d326420492b;hpb=c38ec663ec7b40c65613e5ec26542672b15cdbde;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/20invocations.t b/t/20invocations.t index 51332f8..72054e3 100644 --- a/t/20invocations.t +++ b/t/20invocations.t @@ -1,30 +1,32 @@ use strict; +use warnings; use Test::More; use Test::Warn; use DBIx::Class::Schema::Loader::Optional::Dependencies; +use DBIx::Class::Schema::Loader::Utils qw/sigwarn_silencer/; use lib qw(t/lib); use make_dbictest_db; # Takes a $schema as input, runs 4 basic tests sub test_schema { - my ($testname, $schema) = @_; + my ($testname, $schema) = @_; - warnings_are ( sub { - $schema = $schema->clone if !ref $schema; - isa_ok($schema, 'DBIx::Class::Schema', $testname); + warnings_are { + $schema = $schema->clone if !ref $schema; + isa_ok($schema, 'DBIx::Class::Schema', $testname); - my $rel_foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref'); - isa_ok($rel_foo_rs, 'DBIx::Class::ResultSet', $testname); + my $rel_foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref'); + isa_ok($rel_foo_rs, 'DBIx::Class::ResultSet', $testname); - my $rel_foo = $rel_foo_rs->next; - isa_ok($rel_foo, "DBICTest::Schema::_${testname}::Foo", $testname); + my $rel_foo = $rel_foo_rs->next; + isa_ok($rel_foo, "DBICTest::Schema::_${testname}::Foo", $testname); - is($rel_foo->footext, 'Foo record associated with the Bar with barid 3', "$testname correct object"); + is($rel_foo->footext, 'Foo record associated with the Bar with barid 3', "$testname correct object"); - my $foo_rs = $schema->resultset('Foo'); - my $foo_new = $foo_rs->create({footext => "${testname}_foo"}); - is ($foo_rs->search({footext => "${testname}_foo"})->count, 1, "$testname object created") || die; - }, [], "No warnings during $testname invocations"); + my $foo_rs = $schema->resultset('Foo'); + my $foo_new = $foo_rs->create({footext => "${testname}_foo"}); + is ($foo_rs->search({footext => "${testname}_foo"})->count, 1, "$testname object created") || die; + } [], "No warnings during $testname invocations"; } my @invocations = ( @@ -32,6 +34,7 @@ my @invocations = ( package DBICTest::Schema::_hardcode; use base qw/ DBIx::Class::Schema::Loader /; __PACKAGE__->naming('current'); + __PACKAGE__->use_namespaces(0); __PACKAGE__->connection($make_dbictest_db::dsn); __PACKAGE__; }, @@ -40,13 +43,18 @@ my @invocations = ( use base qw/ DBIx::Class::Schema::Loader /; __PACKAGE__->loader_options(); __PACKAGE__->naming('current'); + __PACKAGE__->use_namespaces(0); __PACKAGE__->connect($make_dbictest_db::dsn); }, 'make_schema_at' => sub { use DBIx::Class::Schema::Loader qw/ make_schema_at /; make_schema_at( 'DBICTest::Schema::_make_schema_at', - { really_erase_my_files => 1, naming => 'current' }, + { + really_erase_my_files => 1, + naming => 'current', + use_namespaces => 0 + }, [ $make_dbictest_db::dsn ], ); DBICTest::Schema::_make_schema_at->clone; @@ -55,6 +63,7 @@ my @invocations = ( package DBICTest::Schema::_embedded_options; use base qw/ DBIx::Class::Schema::Loader /; __PACKAGE__->naming('current'); + __PACKAGE__->use_namespaces(0); __PACKAGE__->connect( $make_dbictest_db::dsn, { loader_options => { really_erase_my_files => 1 } } @@ -64,6 +73,7 @@ my @invocations = ( package DBICTest::Schema::_embedded_options_in_attrs; use base qw/ DBIx::Class::Schema::Loader /; __PACKAGE__->naming('current'); + __PACKAGE__->use_namespaces(0); __PACKAGE__->connect( $make_dbictest_db::dsn, undef, @@ -80,7 +90,8 @@ my @invocations = ( $make_dbictest_db::dsn, { loader_options => { really_erase_my_files => 1, - naming => 'current' + naming => 'current', + use_namespaces => 0, } }, ], ); @@ -91,7 +102,8 @@ my @invocations = ( use base qw/ DBIx::Class::Schema::Loader /; __PACKAGE__->loader_options( really_erase_my_files => 1, - naming => 'current' + naming => 'current', + use_namespaces => 0, ); __PACKAGE__->connect( $make_dbictest_db::dsn, @@ -102,7 +114,11 @@ my @invocations = ( use DBIx::Class::Schema::Loader; DBIx::Class::Schema::Loader::make_schema_at( 'DBICTest::Schema::_make_schema_at_explicit', - { really_erase_my_files => 1, naming => 'current' }, + { + really_erase_my_files => 1, + naming => 'current', + use_namespaces => 0, + }, [ $make_dbictest_db::dsn ], ); DBICTest::Schema::_make_schema_at_explicit->clone; @@ -112,7 +128,11 @@ my @invocations = ( use DBIx::Class::Schema::Loader; DBIx::Class::Schema::Loader::make_schema_at( 'DBICTest::Schema::_no_skip_load_external', - { really_erase_my_files => 1, naming => 'current' }, + { + really_erase_my_files => 1, + naming => 'current', + use_namespaces => 0, + }, [ $make_dbictest_db::dsn ], ); DBICTest::Schema::_no_skip_load_external->clone; @@ -122,7 +142,12 @@ my @invocations = ( use DBIx::Class::Schema::Loader; DBIx::Class::Schema::Loader::make_schema_at( 'DBICTest::Schema::_skip_load_external', - { really_erase_my_files => 1, naming => 'current', skip_load_external => 1 }, + { + really_erase_my_files => 1, + naming => 'current', + use_namespaces => 0, + skip_load_external => 1, + }, [ $make_dbictest_db::dsn ], ); DBICTest::Schema::_skip_load_external->clone; @@ -132,6 +157,7 @@ my @invocations = ( package DBICTest::Schema::_use_moose; use base qw/ DBIx::Class::Schema::Loader /; __PACKAGE__->naming('current'); + __PACKAGE__->use_namespaces(0); __PACKAGE__->connect( $make_dbictest_db::dsn, { loader_options => { use_moose => 1 } } @@ -149,10 +175,10 @@ while(@invocations) { my $cref = shift @invocations; my $schema = do { - local $SIG{__WARN__} = sub { - warn $_[0] unless $_[0] =~ /Deleting existing file .+ due to 'really_erase_my_files' setting/ - }; - $cref->(); + local $SIG{__WARN__} = sigwarn_silencer( + qr/Deleting existing file .+ due to 'really_erase_my_files' setting/ + ); + $cref->(); }; test_schema($style, $schema);