From: Peter Rabbitson Date: Fri, 3 Feb 2012 09:46:06 +0000 (+0100) Subject: Reorganize CDBICompat tests - centralize prereq checks in one place X-Git-Tag: v0.08197~46 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d9bd51956470404b3960871d3413fa98f16961d2;p=dbsrgits%2FDBIx-Class.git Reorganize CDBICompat tests - centralize prereq checks in one place --- diff --git a/lib/DBIx/Class/Optional/Dependencies.pm b/lib/DBIx/Class/Optional/Dependencies.pm index 20fe329..afd41f5 100644 --- a/lib/DBIx/Class/Optional/Dependencies.pm +++ b/lib/DBIx/Class/Optional/Dependencies.pm @@ -231,11 +231,10 @@ my $reqs = { test_cdbicompat => { req => { - 'DBIx::ContextualFetch' => '0', + 'Class::DBI' => 0, 'Class::DBI::Plugin::DeepAbstractSearch' => '0', - 'Class::Trigger' => '0', + %$datetime_basic, 'Time::Piece::MySQL' => '0', - 'Clone' => '0', 'Date::Simple' => '3.03', }, }, diff --git a/t/cdbi/01-columns.t b/t/cdbi/01-columns.t index e0c362b..88b8189 100644 --- a/t/cdbi/01-columns.t +++ b/t/cdbi/01-columns.t @@ -3,11 +3,6 @@ use strict; use Test::More; use lib 't/cdbi/testlib'; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@") : (tests=> 24); -} - #----------------------------------------------------------------------- # Make sure that we can set up columns properly @@ -152,3 +147,4 @@ is join (' ', sort A->columns), 'id', "A columns"; is join (' ', sort A::B->columns), 'b1 id', "A::B columns"; is join (' ', sort A::C->columns), 'c1 c2 c3 id', "A::C columns"; +done_testing; diff --git a/t/cdbi/02-Film.t b/t/cdbi/02-Film.t index 5ef43bb..0885f69 100644 --- a/t/cdbi/02-Film.t +++ b/t/cdbi/02-Film.t @@ -4,14 +4,6 @@ use Scalar::Util 'refaddr'; use namespace::clean; $| = 1; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - } - plan tests => 98; -} - INIT { use lib 't/cdbi/testlib'; use Film; @@ -412,3 +404,5 @@ SKIP: { "Creating and retrieving gives ref to same object"; } + +done_testing; diff --git a/t/cdbi/03-subclassing.t b/t/cdbi/03-subclassing.t index 433999d..9bc77e8 100644 --- a/t/cdbi/03-subclassing.t +++ b/t/cdbi/03-subclassing.t @@ -5,15 +5,6 @@ use Test::More; # Make sure subclasses can be themselves subclassed #---------------------------------------------------------------------- -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; - } - plan tests => 6; -} - use lib 't/cdbi/testlib'; use Film; @@ -28,3 +19,5 @@ ok my $btaste = Film::Threat->retrieve('Bad Taste'), "subclass retrieve"; isa_ok $btaste => "Film::Threat"; isa_ok $btaste => "Film"; is $btaste->Title, 'Bad Taste', 'subclass get()'; + +done_testing; diff --git a/t/cdbi/04-lazy.t b/t/cdbi/04-lazy.t index 1ca4165..d89d1b4 100644 --- a/t/cdbi/04-lazy.t +++ b/t/cdbi/04-lazy.t @@ -7,14 +7,6 @@ use Test::Warn; # Test lazy loading #---------------------------------------------------------------------- -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan $@ - ? (skip_all => 'Class::Trigger and DBIx::ContextualFetch required') - : (tests => 36) - ; -} - INIT { use lib 't/cdbi/testlib'; use Lazy; @@ -179,3 +171,5 @@ SKIP: { # I'm too lazy to set up the proper inflation test. ok !exists $l->{_column_data}{orp}; } + +done_testing; diff --git a/t/cdbi/06-hasa.t b/t/cdbi/06-hasa.t index 760a745..ef49c14 100644 --- a/t/cdbi/06-hasa.t +++ b/t/cdbi/06-hasa.t @@ -1,14 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@"); - } - plan tests => 24; -} - @YA::Film::ISA = 'Film'; #local $SIG{__WARN__} = sub { }; @@ -166,3 +158,4 @@ isa_ok($foo->fav, "Film"); isa_ok $foo, "Film", "Object in after_create trigger"; } +done_testing; diff --git a/t/cdbi/08-inheritcols.t b/t/cdbi/08-inheritcols.t index 83d1fee..93b1bd8 100644 --- a/t/cdbi/08-inheritcols.t +++ b/t/cdbi/08-inheritcols.t @@ -1,11 +1,8 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan $@ ? (skip_all => 'Class::Trigger and DBIx::ContextualFetch required') - : (tests=> 3); -} +use lib 't/cdbi/testlib'; +use DBIC::Test::SQLite; package A; @A::ISA = qw(DBIx::Class::CDBICompat); @@ -23,3 +20,5 @@ package main; is join (' ', sort A->columns), 'id', "A columns"; is join (' ', sort A::B->columns), 'b1 id', "A::B columns"; is join (' ', sort A::C->columns), 'c1 c2 c3 id', "A::C columns"; + +done_testing; diff --git a/t/cdbi/09-has_many.t b/t/cdbi/09-has_many.t index b9048dc..7b2a336 100644 --- a/t/cdbi/09-has_many.t +++ b/t/cdbi/09-has_many.t @@ -1,14 +1,6 @@ use strict; use Test::More; - -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan skip_all => 'Class::Trigger and DBIx::ContextualFetch required' if $@; - plan tests => 31; -} - - use lib 't/cdbi/testlib'; use Film; use Actor; @@ -124,3 +116,5 @@ is($as->Name, 'Arnold Schwarzenegger', "Arnie's still Arnie"); is_deeply [sort map { $_->id } $other_thing->things], [1,2]; } + +done_testing; diff --git a/t/cdbi/11-triggers.t b/t/cdbi/11-triggers.t index 9c3bc07..40ba0bd 100644 --- a/t/cdbi/11-triggers.t +++ b/t/cdbi/11-triggers.t @@ -1,15 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; - } - plan tests => 13; -} - use lib 't/cdbi/testlib'; use Film; @@ -63,3 +54,5 @@ ok $ver->delete, "Delete"; }); Film->create({director => "Me"}); } + +done_testing; diff --git a/t/cdbi/12-filter.t b/t/cdbi/12-filter.t index cecc64c..928bc70 100644 --- a/t/cdbi/12-filter.t +++ b/t/cdbi/12-filter.t @@ -1,15 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; - } - plan tests => 50; -} - use lib 't/cdbi/testlib'; use Actor; use Film; @@ -172,3 +163,5 @@ delete $film->{related_resultsets}; eval { $film->actors->delete_all }; is $@, '', "Deleting again does no harm"; } + +done_testing; diff --git a/t/cdbi/13-constraint.t b/t/cdbi/13-constraint.t index 51b283a..3254196 100644 --- a/t/cdbi/13-constraint.t +++ b/t/cdbi/13-constraint.t @@ -1,14 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - } - plan tests => 23; -} - use lib 't/cdbi/testlib'; use Film; @@ -100,6 +92,8 @@ ok $fred, "Got fred"; is $freeaa && $freeaa->codirector, '2001-03-03', "Set the codirector"; } +done_testing; + __DATA__ use CGI::Untaint; @@ -114,4 +108,3 @@ sub _constrain_by_untaint { return 1; }); } - diff --git a/t/cdbi/14-might_have.t b/t/cdbi/14-might_have.t index a02f987..d79a746 100644 --- a/t/cdbi/14-might_have.t +++ b/t/cdbi/14-might_have.t @@ -1,14 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - } - plan tests => 22; -} - use lib 't/cdbi/testlib'; use Film; use Blurb; @@ -78,4 +70,6 @@ Film->create_test_film; ok $host->info->delete; $host->discard_changes; ok !$host->info, 'relationships rechecked after discard_changes'; -} \ No newline at end of file +} + +done_testing; diff --git a/t/cdbi/15-accessor.t b/t/cdbi/15-accessor.t index 39330e3..574292d 100644 --- a/t/cdbi/15-accessor.t +++ b/t/cdbi/15-accessor.t @@ -1,14 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - } - plan tests => 75; -} - INIT { #local $SIG{__WARN__} = #sub { like $_[0], qr/clashes with built-in method/, $_[0] }; @@ -266,3 +258,5 @@ is $@, '', "No errors"; $_->discard_changes for ($naked, $sandl); } + +done_testing; diff --git a/t/cdbi/16-reserved.t b/t/cdbi/16-reserved.t index 201042b..380c819 100644 --- a/t/cdbi/16-reserved.t +++ b/t/cdbi/16-reserved.t @@ -1,17 +1,9 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - } - plan tests => 5; -} - use lib 't/cdbi/testlib'; -require Film; -require Order; +use Film; +use Order; Film->has_many(orders => 'Order'); Order->has_a(film => 'Film'); @@ -32,3 +24,5 @@ my $infilm = $bto->film; isa_ok $infilm, "Film"; is $infilm->id, $film->id, "Orders hasa Film"; + +done_testing; diff --git a/t/cdbi/18-has_a.t b/t/cdbi/18-has_a.t index a87c9f6..5a8ee2a 100644 --- a/t/cdbi/18-has_a.t +++ b/t/cdbi/18-has_a.t @@ -1,14 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - } - plan tests => 41; -} - use lib 't/cdbi/testlib'; use Film; use Director; @@ -236,3 +228,5 @@ SKIP: { eval { Film->has_a(driector => "Director") }; like $@, qr/driector/, "Sensible error from has_a with incorrect column: $@"; } + +done_testing; diff --git a/t/cdbi/19-set_sql.t b/t/cdbi/19-set_sql.t index 73d9777..85242ed 100644 --- a/t/cdbi/19-set_sql.t +++ b/t/cdbi/19-set_sql.t @@ -1,14 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - } - plan tests => 20; -} - use lib 't/cdbi/testlib'; use Film; use Actor; @@ -128,3 +120,4 @@ Film->set_sql( is $apg[1]->title, "B", "and B"; } +done_testing; diff --git a/t/cdbi/21-iterator.t b/t/cdbi/21-iterator.t index c6f6c3a..d4f397e 100644 --- a/t/cdbi/21-iterator.t +++ b/t/cdbi/21-iterator.t @@ -1,14 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@"); - } - plan tests => 37; -} - use lib 't/cdbi/testlib'; use Film; @@ -92,3 +84,5 @@ my @film = ( is $it, 0; ok !$it, "iterator returns false when no results"; } + +done_testing; diff --git a/t/cdbi/22-deflate_order.t b/t/cdbi/22-deflate_order.t index cdb8c0d..a318850 100644 --- a/t/cdbi/22-deflate_order.t +++ b/t/cdbi/22-deflate_order.t @@ -3,12 +3,12 @@ use strict; use Test::More; -eval "use DBIx::Class::CDBICompat; use Time::Piece::MySQL;"; -if ($@) { - plan (skip_all => "Time::Piece::MySQL, Class::Trigger and DBIx::ContextualFetch required: $@"); -} - use lib 't/cdbi/testlib'; +use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs + +eval { require Time::Piece::MySQL } + or plan skip_all => 'Time::Piece::MySQL required for this test'; + use_ok ('Log'); package main; diff --git a/t/cdbi/22-self_referential.t b/t/cdbi/22-self_referential.t index 91fcb7f..6a99acd 100644 --- a/t/cdbi/22-self_referential.t +++ b/t/cdbi/22-self_referential.t @@ -1,10 +1,5 @@ use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan $@ ? (skip_all => 'Class::Trigger and DBIx::ContextualFetch required') : (tests=> 2); -} - use strict; use lib 't/cdbi/testlib'; @@ -22,4 +17,4 @@ my @aliases = $first->aliases; is( scalar @aliases, 1, 'proper number of aliases' ); is( $aliases[ 0 ]->name, 'Second', 'proper alias' ); - +done_testing; diff --git a/t/cdbi/23-cascade.t b/t/cdbi/23-cascade.t index f91be4a..fdee3f7 100644 --- a/t/cdbi/23-cascade.t +++ b/t/cdbi/23-cascade.t @@ -2,14 +2,6 @@ use strict; use Test::More; use Data::Dumper; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - } - plan tests => 12; -} - INIT { use lib 't/cdbi/testlib'; use Film; @@ -74,3 +66,5 @@ for my $args ({ no_cascade_delete => 1 }, { cascade => "None" }) { # ok eval { $dir->delete }; # is $@, '', "Can delete once films are gone"; #} + +done_testing; diff --git a/t/cdbi/24-meta_info.t b/t/cdbi/24-meta_info.t index 32cc5ca..67a09ab 100644 --- a/t/cdbi/24-meta_info.t +++ b/t/cdbi/24-meta_info.t @@ -1,16 +1,10 @@ use strict; use Test::More; - -BEGIN { - eval "use DBIx::Class::CDBICompat;use Time::Piece;"; - plan skip_all => "Time::Piece, Class::Trigger and DBIx::ContextualFetch required: $@" - if $@; - - plan tests => 12; -} - use Test::Warn; +use lib 't/cdbi/testlib'; +use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs + package Temp::DBI; use base qw(DBIx::Class::CDBICompat); Temp::DBI->columns(All => qw(id date)); @@ -73,3 +67,5 @@ package main; is $date->accessor, 'date'; is $date->args->{inflate}, $strptime_inflate; } + +done_testing; diff --git a/t/cdbi/26-mutator.t b/t/cdbi/26-mutator.t index 54140cb..ad4d645 100644 --- a/t/cdbi/26-mutator.t +++ b/t/cdbi/26-mutator.t @@ -1,13 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@" - if $@; - plan tests => 6; -} - use lib 't/cdbi/testlib'; require Film; @@ -39,3 +32,4 @@ eval { }; is $@, '', "No errors"; +done_testing; diff --git a/t/cdbi/30-pager.t b/t/cdbi/30-pager.t index d26b4e8..cb1cee9 100644 --- a/t/cdbi/30-pager.t +++ b/t/cdbi/30-pager.t @@ -1,14 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - } - plan tests => 6; -} - use lib 't/cdbi/testlib'; use Film; @@ -48,3 +40,5 @@ is( $it->next, undef, "next past end of page ok" ); is( $pager->entries_on_this_page, 2, "entries on second page ok" ); is( $it->next->title, "Film 4", "second page first title ok" ); + +done_testing; diff --git a/t/cdbi/68-inflate_has_a.t b/t/cdbi/68-inflate_has_a.t index 3b3a03f..04abccb 100644 --- a/t/cdbi/68-inflate_has_a.t +++ b/t/cdbi/68-inflate_has_a.t @@ -2,17 +2,14 @@ use strict; use warnings; use Test::More; -use lib qw(t/lib); -use DBICTest; +use lib qw(t/cdbi/testlib); +use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs BEGIN { - eval "use DBIx::Class::CDBICompat; use DateTime 0.55; use Clone;"; - plan skip_all => "Clone, DateTime 0.55, Class::Trigger and DBIx::ContextualFetch required" - if $@; + eval { require DateTime; DateTime->VERSION(0.55) } + or plan skip_all => 'DateTime 0.55 required for this test'; } -plan tests => 6; - my $schema = DBICTest->init_schema(); DBICTest::Schema::CD->load_components(qw/CDBICompat::Relationships/); @@ -59,3 +56,4 @@ $cd->update; ($cd) = $schema->resultset("CD")->search({ year => $now->year }); is( $cd->year->year, $now->year, 'deflate ok' ); +done_testing; diff --git a/t/cdbi/98-failure.t b/t/cdbi/98-failure.t index 918bbf5..73db8ad 100644 --- a/t/cdbi/98-failure.t +++ b/t/cdbi/98-failure.t @@ -5,14 +5,6 @@ use Test::More; # Test database failures #---------------------------------------------------------------------- -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - } - plan tests => 7; -} - use lib 't/cdbi/testlib'; use Film; @@ -58,3 +50,4 @@ if (0) { } } +done_testing; diff --git a/t/cdbi/DeepAbstractSearch/01_search.t b/t/cdbi/DeepAbstractSearch/01_search.t index cc08010..7346138 100644 --- a/t/cdbi/DeepAbstractSearch/01_search.t +++ b/t/cdbi/DeepAbstractSearch/01_search.t @@ -1,16 +1,15 @@ use strict; use Test::More; +use lib 't/cdbi/testlib'; +use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs + BEGIN { - eval "use DBIx::Class::CDBICompat; require Class::DBI::Plugin::DeepAbstractSearch;"; - if ($@) { - plan (skip_all => "Class::DBI::Plugin::DeepAbstractSearch, Class::Trigger and DBIx::ContextualFetch required: $@"); - } - plan tests => 19; + eval { require Class::DBI::Plugin::DeepAbstractSearch } + or plan skip_all => 'Class::DBI::Plugin::DeepAbstractSearch required for this test'; } -my $DB = "t/var/cdbi_testdb"; -unlink $DB if -e $DB; +my $DB = DBICTest->_sqlite_dbname(sqlite_use_file => 1);; # not usre why this test needs an AutoCommit => 0 and a commit further # down - EDONOTCARE @@ -293,5 +292,7 @@ package main; "CDs from Sony or Supraphon"; } +done_testing; + END { unlink $DB if -e $DB } diff --git a/t/cdbi/abstract/search_where.t b/t/cdbi/abstract/search_where.t index 0d98bcc..a14682f 100644 --- a/t/cdbi/abstract/search_where.t +++ b/t/cdbi/abstract/search_where.t @@ -3,14 +3,6 @@ use Test::More; use strict; use warnings; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@"); - } - plan tests => 10; -} - INIT { use lib 't/cdbi/testlib'; use Film; @@ -68,3 +60,4 @@ is_deeply ["Super Fuzz", "Superman"], [map $_->Title, @all], "limit_dialect ignored"; +done_testing; diff --git a/t/cdbi/columns_as_hashes.t b/t/cdbi/columns_as_hashes.t index 5e2d83c..fcb6b17 100644 --- a/t/cdbi/columns_as_hashes.t +++ b/t/cdbi/columns_as_hashes.t @@ -2,11 +2,6 @@ use strict; use Test::More; use Test::Warn; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@" if $@; -} - use lib 't/cdbi/testlib'; use Film; diff --git a/t/cdbi/columns_dont_override_custom_accessors.t b/t/cdbi/columns_dont_override_custom_accessors.t index 6ec7fe1..fdff082 100644 --- a/t/cdbi/columns_dont_override_custom_accessors.t +++ b/t/cdbi/columns_dont_override_custom_accessors.t @@ -2,12 +2,6 @@ use strict; use Test::More; use lib 't/cdbi/testlib'; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@") - : (tests=> 5); -} - { package Thing; @@ -31,3 +25,5 @@ is( $thing->id, 23 ); is( $thing->yarrow, "hock", 'custom accessor not overwritten by column' ); is( $thing->foo, 42, 'custom routine not overwritten by temp column' ); is( $thing->bar, "that", 'temp column accessor generated' ); + +done_testing; diff --git a/t/cdbi/construct.t b/t/cdbi/construct.t index 3e364b3..1e15a34 100644 --- a/t/cdbi/construct.t +++ b/t/cdbi/construct.t @@ -1,12 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@") - : (tests=> 5); -} - INIT { use lib 't/cdbi/testlib'; use Film; @@ -41,3 +35,5 @@ INIT { ::is $film->temp_thing, 23, "construct sets temp columns"; } + +done_testing; diff --git a/t/cdbi/copy.t b/t/cdbi/copy.t index 2550619..bde83ec 100644 --- a/t/cdbi/copy.t +++ b/t/cdbi/copy.t @@ -1,12 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@") - : (tests=> 4); -} - INIT { use lib 't/cdbi/testlib'; } @@ -39,3 +33,4 @@ isnt $new_film->id, $film->id, "copy() gets new primary key"; $new_film = $film->copy(42); is $new_film->id, 42, "copy() with new id"; +done_testing; diff --git a/t/cdbi/early_column_heisenbug.t b/t/cdbi/early_column_heisenbug.t index e6157d0..0dd87b9 100644 --- a/t/cdbi/early_column_heisenbug.t +++ b/t/cdbi/early_column_heisenbug.t @@ -2,11 +2,8 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@" if $@; -} - +use lib 't/cdbi/testlib'; +use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs { package Thing; diff --git a/t/cdbi/has_many_loads_foreign_class.t b/t/cdbi/has_many_loads_foreign_class.t index 51cec5d..4275f65 100644 --- a/t/cdbi/has_many_loads_foreign_class.t +++ b/t/cdbi/has_many_loads_foreign_class.t @@ -2,12 +2,6 @@ use strict; use Test::More; use Class::Inspector (); -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan skip_all => 'Class::Trigger and DBIx::ContextualFetch required' if $@; - plan tests => 3; -} - use lib 't/cdbi/testlib'; use Director; @@ -33,4 +27,6 @@ my $guillotine = Film->create({ Director => "Yu Wang", }); -is_deeply [sort $shan_hua->films], [sort $inframan, $guillotine2]; \ No newline at end of file +is_deeply [sort $shan_hua->films], [sort $inframan, $guillotine2]; + +done_testing; diff --git a/t/cdbi/hasa_without_loading.t b/t/cdbi/hasa_without_loading.t index 073ef3e..8173fdb 100644 --- a/t/cdbi/hasa_without_loading.t +++ b/t/cdbi/hasa_without_loading.t @@ -1,11 +1,8 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan $@ ? (skip_all => 'Class::Trigger and DBIx::ContextualFetch required') - : (tests=> 2); -} +use lib 't/cdbi/testlib'; +use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs package Foo; @@ -19,3 +16,5 @@ eval { #::is $@, ''; ::is(Foo->table, "foo"); ::is_deeply [sort map lc, Foo->columns], [sort map lc, qw(foo bar)]; + +::done_testing; diff --git a/t/cdbi/max_min_value_of.t b/t/cdbi/max_min_value_of.t index a9dfc8f..e9e627e 100644 --- a/t/cdbi/max_min_value_of.t +++ b/t/cdbi/max_min_value_of.t @@ -5,14 +5,6 @@ use Test::More; # Test database failures #---------------------------------------------------------------------- -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - } - plan tests => 2; -} - use lib 't/cdbi/testlib'; use Film; @@ -28,3 +20,5 @@ Film->create({ is( Film->maximum_value_of("numexplodingsheep"), 10 ); is( Film->minimum_value_of("numexplodingsheep"), 2 ); + +done_testing; diff --git a/t/cdbi/mk_group_accessors.t b/t/cdbi/mk_group_accessors.t index f7d4580..fa82c01 100644 --- a/t/cdbi/mk_group_accessors.t +++ b/t/cdbi/mk_group_accessors.t @@ -1,11 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan skip_all => 'Class::Trigger and DBIx::ContextualFetch required' if $@; -} - INIT { use lib 't/cdbi/testlib'; require Film; diff --git a/t/cdbi/multi_column_set.t b/t/cdbi/multi_column_set.t index d6a9484..bae1d4c 100644 --- a/t/cdbi/multi_column_set.t +++ b/t/cdbi/multi_column_set.t @@ -2,12 +2,6 @@ use strict; use Test::More; use lib 't/cdbi/testlib'; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@") - : (tests=> 3); -} - { package Thing; @@ -24,3 +18,5 @@ is $thing->some, "woosh"; is $thing->baz, 99; $thing->discard_changes; + +done_testing; diff --git a/t/cdbi/object_cache.t b/t/cdbi/object_cache.t index d9034c2..a0fdd20 100644 --- a/t/cdbi/object_cache.t +++ b/t/cdbi/object_cache.t @@ -2,12 +2,6 @@ use strict; use Test::More; $| = 1; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - } -} INIT { use lib 't/cdbi/testlib'; @@ -77,3 +71,5 @@ ok +Film->create({ $film1->discard_changes; } + +done_testing; diff --git a/t/cdbi/retrieve_from_sql_with_limit.t b/t/cdbi/retrieve_from_sql_with_limit.t index 70a6128..64dfe03 100644 --- a/t/cdbi/retrieve_from_sql_with_limit.t +++ b/t/cdbi/retrieve_from_sql_with_limit.t @@ -1,12 +1,6 @@ use strict; use Test::More; -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@") - : (tests=> 3); -} - INIT { use lib 't/cdbi/testlib'; use Film; @@ -23,3 +17,5 @@ Film->insert({ Title => "Transformers", Director => "Michael Bay"}); is @films, 2, "retrieve_from_sql with LIMIT"; is( $_->director, "Peter Jackson" ) for @films; } + +done_testing; diff --git a/t/cdbi/set_to_undef.t b/t/cdbi/set_to_undef.t index 2316bf8..20fe77b 100644 --- a/t/cdbi/set_to_undef.t +++ b/t/cdbi/set_to_undef.t @@ -1,12 +1,12 @@ use strict; use Test::More; + use lib 't/cdbi/testlib'; +use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs BEGIN { - eval "use DBIx::Class::CDBICompat;use DateTime 0.55;"; - plan skip_all => "DateTime 0.55, Class::Trigger and DBIx::ContextualFetch required: $@" - if $@; - plan tests => 2; + eval { require DateTime; DateTime->VERSION(0.55) } + or plan skip_all => 'DateTime 0.55 required for this test'; } @@ -30,3 +30,5 @@ is $thing->get( "this" ), undef, 'undef set'; $thing->discard_changes; is @warnings, 0, 'no warnings'; + +done_testing; diff --git a/t/cdbi/set_vs_DateTime.t b/t/cdbi/set_vs_DateTime.t index 48ae9f3..72d69af 100644 --- a/t/cdbi/set_vs_DateTime.t +++ b/t/cdbi/set_vs_DateTime.t @@ -1,13 +1,13 @@ use strict; use Test::More; use Test::Exception; + use lib 't/cdbi/testlib'; +use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs BEGIN { - eval "use DBIx::Class::CDBICompat;use DateTime 0.55;"; - plan skip_all => "DateTime 0.55, Class::Trigger and DBIx::ContextualFetch required: $@" - if $@; - plan tests => 1; + eval { require DateTime; DateTime->VERSION(0.55) } + or plan skip_all => 'DateTime 0.55 required for this test'; } { @@ -25,6 +25,6 @@ lives_ok { $thing->set( date => $date ); }; - - $thing->discard_changes; + +done_testing; diff --git a/t/cdbi/sweet/08pager.t b/t/cdbi/sweet/08pager.t index 2f037cc..f645276 100644 --- a/t/cdbi/sweet/08pager.t +++ b/t/cdbi/sweet/08pager.t @@ -3,17 +3,8 @@ use warnings; use Test::More; -use lib 't/lib'; -use DBICTest; - -BEGIN { - eval "use DBIx::Class::CDBICompat;"; - if ($@) { - plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; - } - plan tests => 9; -} +use lib 't/cdbi/testlib'; +use DBIC::Test::SQLite; DBICTest::Schema::CD->load_components(qw/CDBICompat CDBICompat::Pager/); @@ -80,3 +71,5 @@ for ( map { DBICTest->schema->class($_) } DBICTest->schema->sources ) { no warnings qw/redefine once/; *DBICTest::schema = sub {}; } + +done_testing; diff --git a/t/cdbi/testlib/DBIC/Test/SQLite.pm b/t/cdbi/testlib/DBIC/Test/SQLite.pm index 3934ce6..88d61ef 100644 --- a/t/cdbi/testlib/DBIC/Test/SQLite.pm +++ b/t/cdbi/testlib/DBIC/Test/SQLite.pm @@ -34,6 +34,16 @@ table, and tie it to the class. use strict; use warnings; +use Test::More; + +use lib 't/lib'; +use DBICTest; + +BEGIN { + eval { require DBIx::Class::CDBICompat } + or plan skip_all => 'Class::DBI required for this test'; +} + use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/CDBICompat Core DB/);