Skip to content

Commit

Permalink
Reorganize CDBICompat tests - centralize prereq checks in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
ribasushi committed Apr 9, 2012
1 parent aea59b7 commit d9bd519
Show file tree
Hide file tree
Showing 43 changed files with 115 additions and 297 deletions.
5 changes: 2 additions & 3 deletions lib/DBIx/Class/Optional/Dependencies.pm
Expand Up @@ -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',
},
},
Expand Down
6 changes: 1 addition & 5 deletions t/cdbi/01-columns.t
Expand Up @@ -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
Expand Down Expand Up @@ -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;
10 changes: 2 additions & 8 deletions t/cdbi/02-Film.t
Expand Up @@ -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;
Expand Down Expand Up @@ -412,3 +404,5 @@ SKIP: {
"Creating and retrieving gives ref to same object";

}

done_testing;
11 changes: 2 additions & 9 deletions t/cdbi/03-subclassing.t
Expand Up @@ -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;

Expand All @@ -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;
10 changes: 2 additions & 8 deletions t/cdbi/04-lazy.t
Expand Up @@ -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;
Expand Down Expand Up @@ -179,3 +171,5 @@ SKIP: {
# I'm too lazy to set up the proper inflation test.
ok !exists $l->{_column_data}{orp};
}

done_testing;
9 changes: 1 addition & 8 deletions 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 { };
Expand Down Expand Up @@ -166,3 +158,4 @@ isa_ok($foo->fav, "Film");
isa_ok $foo, "Film", "Object in after_create trigger";
}

done_testing;
9 changes: 4 additions & 5 deletions 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);
Expand All @@ -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;
10 changes: 2 additions & 8 deletions 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;
Expand Down Expand Up @@ -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;
11 changes: 2 additions & 9 deletions 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;

Expand Down Expand Up @@ -63,3 +54,5 @@ ok $ver->delete, "Delete";
});
Film->create({director => "Me"});
}

done_testing;
11 changes: 2 additions & 9 deletions 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;
Expand Down Expand Up @@ -172,3 +163,5 @@ delete $film->{related_resultsets};
eval { $film->actors->delete_all };
is $@, '', "Deleting again does no harm";
}

done_testing;
11 changes: 2 additions & 9 deletions 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;

Expand Down Expand Up @@ -100,6 +92,8 @@ ok $fred, "Got fred";
is $freeaa && $freeaa->codirector, '2001-03-03', "Set the codirector";
}

done_testing;

__DATA__
use CGI::Untaint;
Expand All @@ -114,4 +108,3 @@ sub _constrain_by_untaint {
return 1;
});
}
12 changes: 3 additions & 9 deletions 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;
Expand Down Expand Up @@ -78,4 +70,6 @@ Film->create_test_film;
ok $host->info->delete;
$host->discard_changes;
ok !$host->info, 'relationships rechecked after discard_changes';
}
}

done_testing;
10 changes: 2 additions & 8 deletions 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] };
Expand Down Expand Up @@ -266,3 +258,5 @@ is $@, '', "No errors";

$_->discard_changes for ($naked, $sandl);
}

done_testing;
14 changes: 4 additions & 10 deletions 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');
Expand All @@ -32,3 +24,5 @@ my $infilm = $bto->film;
isa_ok $infilm, "Film";

is $infilm->id, $film->id, "Orders hasa Film";

done_testing;
10 changes: 2 additions & 8 deletions 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;
Expand Down Expand Up @@ -236,3 +228,5 @@ SKIP: {
eval { Film->has_a(driector => "Director") };
like $@, qr/driector/, "Sensible error from has_a with incorrect column: $@";
}

done_testing;
9 changes: 1 addition & 8 deletions 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;
Expand Down Expand Up @@ -128,3 +120,4 @@ Film->set_sql(
is $apg[1]->title, "B", "and B";
}

done_testing;
10 changes: 2 additions & 8 deletions 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;

Expand Down Expand Up @@ -92,3 +84,5 @@ my @film = (
is $it, 0;
ok !$it, "iterator returns false when no results";
}

done_testing;
10 changes: 5 additions & 5 deletions t/cdbi/22-deflate_order.t
Expand Up @@ -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;
Expand Down
7 changes: 1 addition & 6 deletions 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';
Expand All @@ -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;

0 comments on commit d9bd519

Please sign in to comment.