X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcdbi-t%2F01-columns.t;h=4166226d8ecb41fd88368b286009798bf1fb17ae;hb=331a564;hp=0841e1e4db681783efe4377ea77b92a81e7552ce;hpb=9bc6db133eae500322e0e3670d5509d27d208f9e;p=dbsrgits%2FDBIx-Class.git diff --git a/t/cdbi-t/01-columns.t b/t/cdbi-t/01-columns.t index 0841e1e..4166226 100644 --- a/t/cdbi-t/01-columns.t +++ b/t/cdbi-t/01-columns.t @@ -1,13 +1,19 @@ use strict; -use Test::More tests => 25; +use Test::More; + +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 #----------------------------------------------------------------------- package State; -use base 'DBIx::Class'; +use base 'DBIx::Class::Test::SQLite'; State->table('State'); State->columns(Essential => qw/Abbreviation Name/); @@ -16,13 +22,13 @@ State->columns(Weather => qw/Rain Snowfall/); State->columns(Other => qw/Capital Population/); #State->has_many(cities => "City"); -sub accessor_name { +sub accessor_name_for { my ($class, $column) = @_; my $return = $column eq "Rain" ? "Rainfall" : $column; return $return; } -sub mutator_name { +sub mutator_name_for { my ($class, $column) = @_; my $return = $column eq "Rain" ? "set_Rainfall" : "set_$column"; return $return; @@ -33,16 +39,24 @@ sub Snowfall { 1 } package City; -use base 'DBIx::Class'; +use base 'DBIx::Class::Test::SQLite'; City->table('City'); City->columns(All => qw/Name State Population/); -City->has_a(State => 'State'); +{ + # Disable the `no such table' warning + local $SIG{__WARN__} = sub { + my $warning = shift; + warn $warning unless ($warning =~ /\Qno such table: City(1)\E/); + }; + + City->has_a(State => 'State'); +} #------------------------------------------------------------------------- package CD; -use base 'DBIx::Class'; +use base 'DBIx::Class::Test::SQLite'; CD->table('CD'); CD->columns('All' => qw/artist title length/); @@ -100,11 +114,16 @@ ok(!State->find_column('HGLAGAGlAG'), '!find_column HGLAGAGlAG'); is $grps[1], 'Weather', " - Weather"; } -{ - local $SIG{__WARN__} = sub { }; - eval { DBIx::Class->retrieve(1) }; - like $@, qr/Can't retrieve unless primary columns are defined/, "Need primary key for retrieve"; -} +#{ +# +# package DieTest; +# @DieTest::ISA = qw(DBIx::Class); +# DieTest->load_components(qw/CDBICompat::Retrieve Core/); +# package main; +# local $SIG{__WARN__} = sub { }; +# eval { DieTest->retrieve(1) }; +# like $@, qr/unless primary columns are defined/, "Need primary key for retrieve"; +#} #----------------------------------------------------------------------- # Make sure that columns inherit properly @@ -113,14 +132,18 @@ package State; package A; @A::ISA = qw(DBIx::Class); +__PACKAGE__->load_components(qw/CDBICompat Core/); +__PACKAGE__->table('dummy'); __PACKAGE__->columns(Primary => 'id'); package A::B; @A::B::ISA = 'A'; +__PACKAGE__->table('dummy2'); __PACKAGE__->columns(All => qw(id b1)); package A::C; @A::C::ISA = 'A'; +__PACKAGE__->table('dummy3'); __PACKAGE__->columns(All => qw(id c1 c2 c3)); package main;