From: Aran Deltac Date: Thu, 25 May 2006 17:13:31 +0000 (+0000) Subject: Merge 'DBIx-Class-current' into 'reorganize_tests' X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a5f761f70098f84199318b56cc80e3589b8506be;hp=7caeae8f1f792d00b0511106d1b8ddd8b1b59ec1;p=dbsrgits%2FDBIx-Class-Historic.git Merge 'DBIx-Class-current' into 'reorganize_tests' --- diff --git a/t/19quotes.t b/t/19quotes.t index 7a85075..1275db1 100644 --- a/t/19quotes.t +++ b/t/19quotes.t @@ -1,4 +1,6 @@ use strict; +use warnings; + use Test::More; use IO::File; @@ -6,14 +8,13 @@ BEGIN { eval "use DBD::SQLite"; plan $@ ? ( skip_all => 'needs DBD::SQLite for testing' ) - : ( tests => 7 ); + : ( tests => 6 ); } use lib qw(t/lib); use_ok('DBICTest'); - -use_ok('DBICTest::HelperRels'); +DBICTest::init_schema(); DBICTest->schema->storage->sql_maker->quote_char("'"); DBICTest->schema->storage->sql_maker->name_sep('.'); diff --git a/t/31stats.t b/t/31stats.t index a478d28..b358ef0 100644 --- a/t/31stats.t +++ b/t/31stats.t @@ -8,13 +8,13 @@ BEGIN { eval "use DBD::SQLite"; plan $@ ? ( skip_all => 'needs DBD::SQLite for testing' ) - : ( tests => 13 ); + : ( tests => 12 ); } use lib qw(t/lib); use_ok('DBICTest'); -use_ok('DBICTest::HelperRels'); +DBICTest::init_schema(); my $cbworks = 0; diff --git a/t/53delete_related.t b/t/53delete_related.t index f193566..e0cfe12 100644 --- a/t/53delete_related.t +++ b/t/53delete_related.t @@ -3,11 +3,10 @@ use strict; use warnings; use lib qw(t/lib); use DBICTest; -use DBICTest::BasicRels; plan tests => 7; -my $schema = DBICTest->schema; +my $schema = DBICTest->init_schema(); my $total_cds = $schema->resultset('CD')->count; cmp_ok($total_cds, '>', 0, 'need cd records'); @@ -28,3 +27,4 @@ cmp_ok($artist2_cds, '<', $total_cds, 'need more cds than related cds'); ok($artist2->delete_related('cds', {title => {like => '%'}})); cmp_ok($schema->resultset('CD')->count, '==', ($total_cds - $artist2_cds), 'too many cds were deleted'); + diff --git a/t/run/01core.tl b/t/60core.t similarity index 98% rename from t/run/01core.tl rename to t/60core.t index eaad538..6ac90c7 100644 --- a/t/run/01core.tl +++ b/t/60core.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest->init_schema(); plan tests => 60; @@ -88,7 +94,7 @@ $new->name('Man With A Spoon'); $new->update; -$new_again = $schema->resultset("Artist")->find(4); +my $new_again = $schema->resultset("Artist")->find(4); is($new_again->name, 'Man With A Spoon', 'Retrieved correctly'); @@ -278,6 +284,3 @@ ok(!$@, "stringify to false value doesn't cause error"); is_deeply([$schema->source('CD')->columns], [qw/cdid artist title/]); } -} - -1; diff --git a/t/run/04db.tl b/t/64db.t similarity index 91% rename from t/run/04db.tl rename to t/64db.t index 4865d96..5208614 100644 --- a/t/run/04db.tl +++ b/t/64db.t @@ -1,6 +1,12 @@ -sub run_tests { -my $schema = shift; - +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); + plan tests => 3; # add some rows inside a transaction and commit it @@ -48,6 +54,3 @@ my $test_type_info = { }; is_deeply($type_info, $test_type_info, 'columns_info_for - column data types'); -} - -1; diff --git a/t/run/05multipk.tl b/t/65multipk.t similarity index 73% rename from t/run/05multipk.tl rename to t/65multipk.t index e60f006..5cea1fd 100644 --- a/t/run/05multipk.tl +++ b/t/65multipk.t @@ -1,13 +1,17 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); plan tests => 4; -$artist = DBICTest::Artist->find(1); + +my $artist = DBICTest::Artist->find(1); ok($artist->find_related('twokeys', {cd => 1}), "find multiple pks using relationships + args"); ok($schema->resultset("FourKeys")->find(1,2,3,4), "find multiple pks without hash"); ok($schema->resultset("FourKeys")->find(5,4,3,6), "find multiple pks without hash"); is($schema->resultset("FourKeys")->find(1,2,3,4)->ID, 'DBICTest::FourKeys|fourkeys|bar=2|foo=1|goodbye=4|hello=3', 'unique object id ok for multiple pks'); -} - -1; diff --git a/t/run/06relationship.tl b/t/66relationship.t similarity index 94% rename from t/run/06relationship.tl rename to t/66relationship.t index 78b857f..45ed343 100644 --- a/t/run/06relationship.tl +++ b/t/66relationship.t @@ -1,11 +1,12 @@ +use strict; +use warnings; + use Test::More; use lib qw(t/lib); use DBICTest; my $schema = DBICTest::init_schema(); -use strict; -use warnings; plan tests => 32; # has_a test @@ -59,11 +60,7 @@ my $track = $schema->resultset("Track")->create( { } ); $track->set_from_related( cd => $cd ); -if ($INC{'DBICTest/HelperRels.pm'}) { # expect inflated object - is($track->disc->cdid, 4, 'set_from_related ok, including alternative accessor' ); -} else { - is( $track->cd, 4, 'set_from_related ok' ); -} +is($track->disc->cdid, 4, 'set_from_related ok, including alternative accessor' ); $track->set_from_related( cd => undef ); @@ -81,11 +78,7 @@ $track->update_from_related( cd => $cd ); my $t_cd = ($schema->resultset("Track")->search( cd => 4, position => 99 ))[0]->cd; -if ($INC{'DBICTest/HelperRels.pm'}) { # except inflated object - is( $t_cd->cdid, 4, 'update_from_related ok' ); -} else { - is( $t_cd, 4, 'update_from_related ok' ); -} +is( $t_cd->cdid, 4, 'update_from_related ok' ); # find_or_create_related with an existing record $cd = $artist->find_or_create_related( 'cds', { title => 'Big Flop' } ); diff --git a/t/run/07pager.tl b/t/67pager.t similarity index 92% rename from t/run/07pager.tl rename to t/67pager.t index d864afa..85b1e8d 100644 --- a/t/run/07pager.tl +++ b/t/67pager.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); plan tests => 12; @@ -62,6 +68,3 @@ is( $it->count, 2, "software count on paged rs ok" ); is( $it->next->title, "Generic Manufactured Singles", "software iterator->next ok" ); -} - -1; diff --git a/t/run/08inflate.tl b/t/68inflate.t similarity index 84% rename from t/run/08inflate.tl rename to t/68inflate.t index e21a6c6..3906a02 100644 --- a/t/run/08inflate.tl +++ b/t/68inflate.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); eval { require DateTime }; plan skip_all => "Need DateTime for inflation tests" if $@; @@ -27,6 +33,3 @@ $cd->update; ($cd) = $schema->resultset("CD")->search( year => $now->year ); is( $cd->year->year, $now->year, 'deflate ok' ); -} - -1; diff --git a/t/run/08inflate_has_a.tl b/t/68inflate_has_a.t similarity index 91% rename from t/run/08inflate_has_a.tl rename to t/68inflate_has_a.t index 50f78c4..266585a 100644 --- a/t/run/08inflate_has_a.tl +++ b/t/68inflate_has_a.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); eval { require DateTime }; plan skip_all => "Need DateTime for inflation tests" if $@; @@ -50,6 +56,3 @@ $cd->update; ($cd) = $schema->resultset("CD")->search( year => $now->year ); is( $cd->year->year, $now->year, 'deflate ok' ); -} - -1; diff --git a/t/run/08inflate_serialize.tl b/t/68inflate_serialize.t similarity index 93% rename from t/run/08inflate_serialize.tl rename to t/68inflate_serialize.t index ae5ca7a..b51f961 100644 --- a/t/run/08inflate_serialize.tl +++ b/t/68inflate_serialize.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); use Data::Dumper; @@ -67,6 +73,3 @@ ok($entry->update ({ %{$complex2} }), 'arrayref deflation ok'); ok($inflated = $entry->serialized, 'arrayref inflation ok'); is_deeply($inflated, $complex2->{serialized}, 'inflated array matches original'); -} - -1; diff --git a/t/run/09update.tl b/t/69update.t similarity index 83% rename from t/run/09update.tl rename to t/69update.t index ff802f0..70d7038 100644 --- a/t/run/09update.tl +++ b/t/69update.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); BEGIN { eval "use DBD::SQLite"; @@ -21,6 +27,3 @@ ok($art->name($name) eq $name, 'update'); $art->discard_changes; -} - -1; diff --git a/t/run/10auto.tl b/t/70auto.t similarity index 81% rename from t/run/10auto.tl rename to t/70auto.t index 7c795f4..b108369 100644 --- a/t/run/10auto.tl +++ b/t/70auto.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); plan tests => 2; @@ -14,6 +20,3 @@ ok($artist->update, 'update on object created without PK ok'); my $copied = $artist->copy({ name => 'Don\'t tell the RIAA', artistid => undef }); is($copied->name, 'Don\'t tell the RIAA', "Copied with PKs ok."); -} - -1; diff --git a/t/run/11mysql.tl b/t/71mysql.t similarity index 91% rename from t/run/11mysql.tl rename to t/71mysql.t index 15664d9..93f45fd 100644 --- a/t/run/11mysql.tl +++ b/t/71mysql.t @@ -1,11 +1,15 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}; #warn "$dsn $user $pass"; -plan skip_all, 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test' +plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); plan tests => 5; @@ -71,6 +75,3 @@ is_deeply($type_info, $test_type_info, 'columns_info_for - column data types'); # clean up our mess $dbh->do("DROP TABLE artist"); -} - -1; diff --git a/t/run/12pg.tl b/t/72pg.t similarity index 90% rename from t/run/12pg.tl rename to t/72pg.t index 5432a60..3e55bcb 100644 --- a/t/run/12pg.tl +++ b/t/72pg.t @@ -1,11 +1,16 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; #warn "$dsn $user $pass"; -plan skip_all, 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' - . ' (note: creates and drops tables named artist and casecheck!)' unless ($dsn && $user); +plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' + . ' (note: creates and drops tables named artist and casecheck!)' unless ($dsn && $user); plan tests => 8; @@ -14,7 +19,6 @@ DBICTest::Schema->compose_connection('PgTest' => $dsn, $user, $pass); my $dbh = PgTest->schema->storage->dbh; PgTest->schema->source("Artist")->name("testschema.artist"); $dbh->do("CREATE SCHEMA testschema;"); - $dbh->do("CREATE TABLE testschema.artist (artistid serial PRIMARY KEY, name VARCHAR(100), charfield CHAR(10));"); ok ( $dbh->do('CREATE TABLE testschema.casecheck (id serial PRIMARY KEY, "name" VARCHAR(1), "NAME" VARCHAR(2), "UC_NAME" VARCHAR(3));'), 'Creation of casecheck table'); @@ -70,6 +74,3 @@ $dbh->do("DROP TABLE testschema.artist;"); $dbh->do("DROP TABLE testschema.casecheck;"); $dbh->do("DROP SCHEMA testschema;"); -} - -1; diff --git a/t/run/13oracle.tl b/t/73oracle.t similarity index 91% rename from t/run/13oracle.tl rename to t/73oracle.t index f38b767..c0489ff 100644 --- a/t/run/13oracle.tl +++ b/t/73oracle.t @@ -1,9 +1,13 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/}; -plan skip_all, 'Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test. ' . +plan skip_all => 'Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test. ' . 'Warning: This test drops and creates tables called \'artist\', \'cd\' and \'track\'' unless ($dsn && $user && $pass); @@ -61,8 +65,8 @@ my $other_track = OraTest::Track->create({ trackid => 2, cd => 1, position => 1, my $tcount = OraTest::Track->search( {}, { - select => [{count => {distinct => ['position', 'title']}}], - as => ['count'] + select => [{count => {distinct => ['position', 'title']}}], + as => ['count'] } ); @@ -89,6 +93,3 @@ $dbh->do("DROP TABLE artist"); $dbh->do("DROP TABLE cd"); $dbh->do("DROP TABLE track"); -} - -1; diff --git a/t/run/145db2.tl b/t/745db2.t similarity index 91% rename from t/run/145db2.tl rename to t/745db2.t index 31e3461..ffb7a0b 100644 --- a/t/run/145db2.tl +++ b/t/745db2.t @@ -1,11 +1,15 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_${_}" } qw/DSN USER PASS/}; #warn "$dsn $user $pass"; -plan skip_all, 'Set $ENV{DBICTEST_DB2_DSN}, _USER and _PASS to run this test' +plan skip_all => 'Set $ENV{DBICTEST_DB2_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); plan tests => 6; @@ -68,6 +72,3 @@ is_deeply($type_info, $test_type_info, 'columns_info_for - column data types'); # clean up our mess $dbh->do("DROP TABLE artist"); -} - -1; diff --git a/t/run/146db2_400.tl b/t/746db2_400.t similarity index 91% rename from t/run/146db2_400.tl rename to t/746db2_400.t index ac6cd47..558ca62 100644 --- a/t/run/146db2_400.tl +++ b/t/746db2_400.t @@ -1,5 +1,9 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_400_${_}" } qw/DSN USER PASS/}; @@ -8,7 +12,7 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_400_${_}" } qw/DSN USER PASS/ # Probably best to pass the DBQ option in the DSN to specify a specific # libray. Something like: # DBICTEST_DB2_400_DSN='dbi:ODBC:dsn=MyAS400;DBQ=MYLIB' -plan skip_all, 'Set $ENV{DBICTEST_DB2_400_DSN}, _USER and _PASS to run this test' +plan skip_all => 'Set $ENV{DBICTEST_DB2_400_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); plan tests => 6; @@ -69,6 +73,3 @@ is_deeply($type_info, $test_type_info, 'columns_info_for - column data types'); # clean up our mess $dbh->do("DROP TABLE artist"); -} - -1; diff --git a/t/run/14mssql.tl b/t/74mssql.t similarity index 79% rename from t/run/14mssql.tl rename to t/74mssql.t index befc14d..c879ca6 100644 --- a/t/run/14mssql.tl +++ b/t/74mssql.t @@ -1,16 +1,20 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/}; #warn "$dsn $user $pass"; -plan skip_all, 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test' +plan skip_all => 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test' unless ($dsn); plan tests => 4; -$schema->compose_connection( 'MSSQLTest' => $dsn, $user, $pass ); +DBICTest::Schema->compose_connection( 'MSSQLTest' => $dsn, $user, $pass ); my $dbh = MSSQLTest->schema->storage->dbh; @@ -43,6 +47,3 @@ $it->next; $it->next; is( $it->next, undef, "next past end of resultset ok" ); -} - -1; diff --git a/t/run/15limit.tl b/t/75limit.t similarity index 93% rename from t/run/15limit.tl rename to t/75limit.t index eca720d..98d3b64 100644 --- a/t/run/15limit.tl +++ b/t/75limit.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); BEGIN { eval "use DBD::SQLite"; @@ -62,6 +68,3 @@ $it = $schema->resultset("CD")->search( ); is( $it->count, 1, "complex abstract count ok" ); -} - -1; diff --git a/t/run/16joins.tl b/t/76joins.t similarity index 98% rename from t/run/16joins.tl rename to t/76joins.t index c83aa7c..069626a 100644 --- a/t/run/16joins.tl +++ b/t/76joins.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); use IO::File; @@ -273,6 +279,3 @@ $schema->storage->debug(0); cmp_ok($queries, '==', 1, 'Only one query run'); -} # end run_tests - -1; diff --git a/t/run/17join_count.tl b/t/77join_count.t similarity index 87% rename from t/run/17join_count.tl rename to t/77join_count.t index 08335e0..499b08f 100644 --- a/t/run/17join_count.tl +++ b/t/77join_count.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); eval "use DBD::SQLite"; plan skip_all => 'needs DBD::SQLite for testing' if $@; @@ -23,6 +29,3 @@ cmp_ok($schema->resultset("CD")->count( { join => [ qw/tags liner_notes/ ] } ), '==', 2, "Mixed count ok"); -} - -1; diff --git a/t/run/18self_referencial.tl b/t/78self_referencial.t similarity index 88% rename from t/run/18self_referencial.tl rename to t/78self_referencial.t index b061adb..5759aca 100644 --- a/t/run/18self_referencial.tl +++ b/t/78self_referencial.t @@ -1,39 +1,42 @@ -sub run_tests { -my $schema = shift; - -# this test will check to see if you can have 2 columns -# in the same class pointing at the same other class -# -# example: -# -# +---------+ +--------------+ -# | SelfRef | | SelfRefAlias | -# +---------+ 1-M +--------------+ -# | id |-------| self_ref | --+ -# | name | | alias | --+ -# +---------+ +--------------+ | -# /|\ | -# | | -# +--------------------------------+ -# -# see http://use.perl.org/~LTjake/journal/24876 for the -# issue with CDBI - -plan tests => 4; - -my $item = $schema->resultset("SelfRef")->find( 1 ); -is( $item->name, 'First', 'proper start item' ); - -my @aliases = $item->aliases; - -is( scalar @aliases, 1, 'proper number of aliases' ); - -my $orig = $aliases[ 0 ]->self_ref; -my $alias = $aliases[ 0 ]->alias; - -is( $orig->name, 'First', 'proper original' ); -is( $alias->name, 'Second', 'proper alias' ); - -} - -1; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); + +# this test will check to see if you can have 2 columns +# in the same class pointing at the same other class +# +# example: +# +# +---------+ +--------------+ +# | SelfRef | | SelfRefAlias | +# +---------+ 1-M +--------------+ +# | id |-------| self_ref | --+ +# | name | | alias | --+ +# +---------+ +--------------+ | +# /|\ | +# | | +# +--------------------------------+ +# +# see http://use.perl.org/~LTjake/journal/24876 for the +# issue with CDBI + +plan tests => 4; + +my $item = $schema->resultset("SelfRef")->find( 1 ); +is( $item->name, 'First', 'proper start item' ); + +my @aliases = $item->aliases; + +is( scalar @aliases, 1, 'proper number of aliases' ); + +my $orig = $aliases[ 0 ]->self_ref; +my $alias = $aliases[ 0 ]->alias; + +is( $orig->name, 'First', 'proper original' ); +is( $alias->name, 'Second', 'proper alias' ); + diff --git a/t/run/19uuid.tl b/t/79uuid.t similarity index 64% rename from t/run/19uuid.tl rename to t/79uuid.t index 0da87f1..04fcca6 100644 --- a/t/run/19uuid.tl +++ b/t/79uuid.t @@ -1,8 +1,14 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); eval 'use Data::UUID ; 1' - or plan skip_all, 'Install Data::UUID run this test'; + or plan skip_all => 'Install Data::UUID run this test'; plan tests => 1; DBICTest::Schema::Artist->load_components('UUIDColumns'); @@ -12,6 +18,3 @@ Class::C3->reinitialize(); my $artist = $schema->resultset("Artist")->create( { artistid => 100 } ); like $artist->name, qr/[\w-]{36}/, 'got something like uuid'; -} - -1; diff --git a/t/run/20unique.tl b/t/80unique.t similarity index 96% rename from t/run/20unique.tl rename to t/80unique.t index 19481ef..9d7634c 100644 --- a/t/run/20unique.tl +++ b/t/80unique.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); plan tests => 34; @@ -119,6 +125,3 @@ is($cd9->get_column('artist'), $cd1->get_column('artist'), 'artist is correct'); is($cd9->title, $cd1->title, 'title is correct'); is($cd9->year, 2021, 'year is correct'); -} - -1; diff --git a/t/run/21transactions.tl b/t/81transactions.t similarity index 97% rename from t/run/21transactions.tl rename to t/81transactions.t index eafc575..c9d9c62 100644 --- a/t/run/21transactions.tl +++ b/t/81transactions.t @@ -1,5 +1,12 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); + plan tests => 39; my $code = sub { @@ -110,6 +117,7 @@ my $fail_code = sub { # Force txn_rollback() to throw an exception no warnings 'redefine'; + no strict 'refs'; local *{"DBIx::Class::Schema::txn_rollback"} = sub{die 'FAILED'}; eval { @@ -169,6 +177,4 @@ my $fail_code = sub { })->first; ok(!defined($cd), q{failed txn_do didn't add failed txn's cd}); } -} -1; diff --git a/t/run/22cascade_copy.tl b/t/82cascade_copy.t similarity index 88% rename from t/run/22cascade_copy.tl rename to t/82cascade_copy.t index 82642f2..e5048a1 100644 --- a/t/run/22cascade_copy.tl +++ b/t/82cascade_copy.t @@ -1,8 +1,11 @@ use strict; -use warnings; +use warnings; -sub run_tests { -my $schema = shift; +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); plan tests => 4; my $artist = $schema->resultset('Artist')->find(1); @@ -28,5 +31,3 @@ cmp_ok($cover_band->search_related('twokeys')->count, '>', 0, 'duplicated multiP cmp_ok($cover_cds->search_related('tags')->count, '==', $artist_cds->search_related('tags')->count , 'duplicated count ok'); -} -1; diff --git a/t/run/23cache.tl b/t/83cache.t similarity index 96% rename from t/run/23cache.tl rename to t/83cache.t index a822601..39f782a 100644 --- a/t/run/23cache.tl +++ b/t/83cache.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); my $queries; $schema->storage->debugcb( sub{ $queries++ } ); @@ -34,7 +40,7 @@ $rs->set_cache( $artists ); is( scalar @{$rs->get_cache}, 2, 'set_cache() is functional' ); -$cd = $schema->resultset('CD')->find(1); +my $cd = $schema->resultset('CD')->find(1); $rs->clear_cache; @@ -173,6 +179,3 @@ is( $queries, 1, 'only one select statement on find with has_many prefetch on re $schema->storage->debug(0); -} - -1; diff --git a/t/run/24serialize.tl b/t/84serialize.t similarity index 62% rename from t/run/24serialize.tl rename to t/84serialize.t index 7c746f2..d79acba 100644 --- a/t/run/24serialize.tl +++ b/t/84serialize.t @@ -1,7 +1,12 @@ +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; use Storable; -sub run_tests { -my $schema = shift; +my $schema = DBICTest::init_schema(); plan tests => 1; @@ -9,6 +14,3 @@ my $artist = $schema->resultset('Artist')->find(1); my $copy = eval { Storable::dclone($artist) }; is_deeply($copy, $artist, 'serialize row object works'); -} - -1; diff --git a/t/85utf8.t b/t/85utf8.t new file mode 100644 index 0000000..c0f39ed --- /dev/null +++ b/t/85utf8.t @@ -0,0 +1,27 @@ +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); + +eval 'use Encode ; 1' + or plan skip_all => 'Install Encode run this test'; + +plan tests => 2; + +DBICTest::Schema::Artist->load_components('UTF8Columns'); +DBICTest::Schema::Artist->utf8_columns('name'); +Class::C3->reinitialize(); + +my $artist = $schema->resultset("Artist")->create( { name => 'uni' } ); +ok( Encode::is_utf8( $artist->name ), 'got name with utf8 flag' ); + +my $utf8_char = 'uniuni'; +Encode::_utf8_on($utf8_char); +$artist->name($utf8_char); +ok( !Encode::is_utf8( $artist->{_column_data}->{name} ), + 'store utf8 less chars' ); + diff --git a/t/run/26might_have.tl b/t/86might_have.t similarity index 87% rename from t/run/26might_have.tl rename to t/86might_have.t index 0b700e8..1d4af78 100644 --- a/t/run/26might_have.tl +++ b/t/86might_have.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); my $queries; #$schema->storage->debugfh(IO::File->new('t/var/temp.trace', 'w')); @@ -38,6 +44,4 @@ is($queries, 1, 'liner_notes (might_have) prefetched - do not load liner_notes on update'); $schema->storage->debug(0); -} -1; diff --git a/t/helperrels/26sqlt.t b/t/86sqlt.t similarity index 98% rename from t/helperrels/26sqlt.t rename to t/86sqlt.t index 4452bd5..d01a630 100644 --- a/t/helperrels/26sqlt.t +++ b/t/86sqlt.t @@ -1,14 +1,16 @@ +use strict; +use warnings; + use Test::More; use lib qw(t/lib); use DBICTest; -use DBICTest::HelperRels; eval "use SQL::Translator"; plan skip_all => 'SQL::Translator required' if $@; # do not taunt happy dave ball -my $schema = DBICTest::Schema; +my $schema = 'DBICTest::Schema'; plan tests => 31; @@ -177,6 +179,8 @@ sub check_fk { return 0; } +my( $ondel, $onupd ); + sub check_unique { my ($selftable, $selfcol) = @_; diff --git a/t/run/27ordered.tl b/t/87ordered.t similarity index 69% rename from t/run/27ordered.tl rename to t/87ordered.t index 3a53951..1e4f33a 100644 --- a/t/run/27ordered.tl +++ b/t/87ordered.t @@ -1,39 +1,40 @@ # vim: filetype=perl +use strict; +use warnings; -sub run_tests { +use Test::More; +use lib qw(t/lib); +use DBICTest; - plan tests => 321; - my $schema = shift; +my $schema = DBICTest::init_schema(); - my $employees = $schema->resultset('Employee'); - $employees->delete(); +plan tests => 321; - foreach (1..5) { - $employees->create({ name=>'temp' }); - } - $employees = $employees->search(undef,{order_by=>'position'}); - ok( check_rs($employees), "intial positions" ); - - hammer_rs( $employees ); +my $employees = $schema->resultset('Employee'); +$employees->delete(); - #return; +foreach (1..5) { + $employees->create({ name=>'temp' }); +} +$employees = $employees->search(undef,{order_by=>'position'}); +ok( check_rs($employees), "intial positions" ); - DBICTest::Employee->grouping_column('group_id'); - $employees->delete(); - foreach my $group_id (1..3) { - foreach (1..6) { - $employees->create({ name=>'temp', group_id=>$group_id }); - } - } - $employees = $employees->search(undef,{order_by=>'group_id,position'}); +hammer_rs( $employees ); - foreach my $group_id (1..3) { - my $group_employees = $employees->search({group_id=>$group_id}); - $group_employees->all(); - ok( check_rs($group_employees), "group intial positions" ); - hammer_rs( $group_employees ); +DBICTest::Employee->grouping_column('group_id'); +$employees->delete(); +foreach my $group_id (1..3) { + foreach (1..6) { + $employees->create({ name=>'temp', group_id=>$group_id }); } +} +$employees = $employees->search(undef,{order_by=>'group_id,position'}); +foreach my $group_id (1..3) { + my $group_employees = $employees->search({group_id=>$group_id}); + $group_employees->all(); + ok( check_rs($group_employees), "group intial positions" ); + hammer_rs( $group_employees ); } sub hammer_rs { @@ -41,6 +42,7 @@ sub hammer_rs { my $employee; my $count = $rs->count(); my $position_column = $rs->result_class->position_column(); + my $row; foreach my $position (1..$count) { @@ -101,4 +103,3 @@ sub check_rs { return 1; } -1; diff --git a/t/run/28result_set_column.tl b/t/88result_set_column.t similarity index 88% rename from t/run/28result_set_column.tl rename to t/88result_set_column.t index 8898878..5ed86d4 100644 --- a/t/run/28result_set_column.tl +++ b/t/88result_set_column.t @@ -1,8 +1,15 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); plan tests => 8; +my $cd; my $rs = $cd = $schema->resultset("CD")->search({}); my $rs_title = $rs->get_column('title'); @@ -34,6 +41,4 @@ $psrs = $schema->resultset('CD')->search({}, ); ok(defined($psrs->get_column('count')), '+select/+as arrayref count'); ok(defined($psrs->get_column('addedtitle')), '+select/+as title'); -} -1; diff --git a/t/89dbicadmin.t b/t/89dbicadmin.t new file mode 100644 index 0000000..a411eb7 --- /dev/null +++ b/t/89dbicadmin.t @@ -0,0 +1,41 @@ +# vim: filetype=perl +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest::init_schema(); + +eval 'require JSON'; +plan skip_all => 'Install JSON to run this test' if ($@); + +eval 'require Text::CSV_XS'; +if ($@) { + eval 'require Text::CSV_PP'; + plan skip_all => 'Install Text::CSV_XS or Text::CSV_PP to run this test' if ($@); +} + +plan tests => 5; + +my $employees = $schema->resultset('Employee'); +my $cmd = qq|script/dbicadmin --schema=DBICTest::Schema --class=Employee --tlibs --connect='["dbi:SQLite:dbname=t/var/DBIxClass.db","",""]' --force --tlibs|; + +`$cmd --op=insert --set='{name:"Matt"}'`; +ok( ($employees->count()==1), 'insert count' ); + +my $employee = $employees->find(1); +ok( ($employee->name() eq 'Matt'), 'insert valid' ); + +`$cmd --op=update --set='{name:"Trout"}'`; +$employee = $employees->find(1); +ok( ($employee->name() eq 'Trout'), 'update' ); + +`$cmd --op=insert --set='{name:"Aran"}'`; +my $data = `$cmd --op=select --attrs='{order_by:"name"}'`; +ok( ($data=~/Aran.*Trout/s), 'select with attrs' ); + +`$cmd --op=delete --where='{name:"Trout"}'`; +ok( ($employees->count()==1), 'delete' ); + diff --git a/t/run/29inflate_datetime.tl b/t/89inflate_datetime.t similarity index 74% rename from t/run/29inflate_datetime.tl rename to t/89inflate_datetime.t index 0efc45a..254348a 100644 --- a/t/run/29inflate_datetime.tl +++ b/t/89inflate_datetime.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest->init_schema(); eval { require DateTime::Format::MySQL }; plan skip_all => "Need DateTime::Format::MySQL for inflation tests" if $@; @@ -13,6 +19,3 @@ isa_ok($event->starts_at, 'DateTime', 'DateTime returned'); is($event->starts_at, '2006-04-25T22:24:33', 'Correct date/time'); -} - -1; diff --git a/t/run/30ensure_class_loaded.tl b/t/90ensure_class_loaded.t similarity index 87% rename from t/run/30ensure_class_loaded.tl rename to t/90ensure_class_loaded.t index 8602565..8f66c2e 100644 --- a/t/run/30ensure_class_loaded.tl +++ b/t/90ensure_class_loaded.t @@ -1,3 +1,9 @@ +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; use Class::Inspector; BEGIN { @@ -5,9 +11,8 @@ BEGIN { sub some_method {} } -sub run_tests { +my $schema = DBICTest->init_schema(); -my $schema = shift; plan tests => 6; ok(Class::Inspector->loaded('TestPackage::A'), @@ -35,6 +40,5 @@ eval { ok(!$@, 'ensure_class_loaded detected an existing but non-loaded class'); ok(Class::Inspector->loaded('DBICTest::FakeComponent'), 'DBICTest::FakeComponent now loaded'); -} 1; diff --git a/t/run/30join_torture.tl b/t/90join_torture.t similarity index 87% rename from t/run/30join_torture.tl rename to t/90join_torture.t index 181a94e..eb66445 100644 --- a/t/run/30join_torture.tl +++ b/t/90join_torture.t @@ -1,5 +1,11 @@ -sub run_tests { -my $schema = shift; +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest->init_schema(); plan tests => 4; @@ -20,6 +26,4 @@ is($rs4_results[0]->cdid, 1, "correct artist returned"); my $rs5 = $rs4->search({'tracks.title' => 'Sticky Honey'}); is($rs5->count, 1, "search without using previous joins okay"); -} - 1; diff --git a/t/basicrels/01core.t b/t/basicrels/01core.t deleted file mode 100644 index ac97f9c..0000000 --- a/t/basicrels/01core.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/01core.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/04db.t b/t/basicrels/04db.t deleted file mode 100644 index 67aa083..0000000 --- a/t/basicrels/04db.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/04db.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/05multipk.t b/t/basicrels/05multipk.t deleted file mode 100644 index 1bc84b3..0000000 --- a/t/basicrels/05multipk.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/05multipk.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/06relationship.t b/t/basicrels/06relationship.t deleted file mode 100644 index 04a9afb..0000000 --- a/t/basicrels/06relationship.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/06relationship.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/07pager.t b/t/basicrels/07pager.t deleted file mode 100644 index ff1a778..0000000 --- a/t/basicrels/07pager.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/07pager.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/08inflate.t b/t/basicrels/08inflate.t deleted file mode 100644 index e35bf0f..0000000 --- a/t/basicrels/08inflate.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/08inflate.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/08inflate_has_a.t b/t/basicrels/08inflate_has_a.t deleted file mode 100644 index 187b174..0000000 --- a/t/basicrels/08inflate_has_a.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/08inflate_has_a.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/08inflate_serialize.t b/t/basicrels/08inflate_serialize.t deleted file mode 100644 index 3676643..0000000 --- a/t/basicrels/08inflate_serialize.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/08inflate_serialize.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/09update.t b/t/basicrels/09update.t deleted file mode 100644 index 2b483ed..0000000 --- a/t/basicrels/09update.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/09update.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/10auto.t b/t/basicrels/10auto.t deleted file mode 100644 index 6e7fffb..0000000 --- a/t/basicrels/10auto.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/10auto.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/11mysql.t b/t/basicrels/11mysql.t deleted file mode 100644 index 4b3226b..0000000 --- a/t/basicrels/11mysql.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/11mysql.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/12pg.t b/t/basicrels/12pg.t deleted file mode 100644 index 1953df4..0000000 --- a/t/basicrels/12pg.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/12pg.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/13oracle.t b/t/basicrels/13oracle.t deleted file mode 100644 index 54521ea..0000000 --- a/t/basicrels/13oracle.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/13oracle.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/145db2.t b/t/basicrels/145db2.t deleted file mode 100644 index 9573802..0000000 --- a/t/basicrels/145db2.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/145db2.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/146db2_400.t b/t/basicrels/146db2_400.t deleted file mode 100644 index 2ac494c..0000000 --- a/t/basicrels/146db2_400.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/146db2_400.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/14mssql.t b/t/basicrels/14mssql.t deleted file mode 100644 index 1417499..0000000 --- a/t/basicrels/14mssql.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/14mssql.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/15limit.t b/t/basicrels/15limit.t deleted file mode 100644 index 496d1b4..0000000 --- a/t/basicrels/15limit.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/15limit.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/16joins.t b/t/basicrels/16joins.t deleted file mode 100644 index 436b0d0..0000000 --- a/t/basicrels/16joins.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/16joins.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/17join_count.t b/t/basicrels/17join_count.t deleted file mode 100644 index 8d20fde..0000000 --- a/t/basicrels/17join_count.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/17join_count.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/18self_referencial.t b/t/basicrels/18self_referencial.t deleted file mode 100644 index 798d6a2..0000000 --- a/t/basicrels/18self_referencial.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/18self_referencial.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/19uuid.t b/t/basicrels/19uuid.t deleted file mode 100644 index ec8222a..0000000 --- a/t/basicrels/19uuid.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/19uuid.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/20unique.t b/t/basicrels/20unique.t deleted file mode 100644 index 5a87ef1..0000000 --- a/t/basicrels/20unique.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/20unique.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/21transactions.t b/t/basicrels/21transactions.t deleted file mode 100644 index cea95cf..0000000 --- a/t/basicrels/21transactions.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/21transactions.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/22cascade_copy.t b/t/basicrels/22cascade_copy.t deleted file mode 100644 index c670152..0000000 --- a/t/basicrels/22cascade_copy.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/22cascade_copy.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/23cache.t b/t/basicrels/23cache.t deleted file mode 100644 index ca2efee..0000000 --- a/t/basicrels/23cache.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/23cache.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/24serialize.t b/t/basicrels/24serialize.t deleted file mode 100644 index 1a11191..0000000 --- a/t/basicrels/24serialize.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/24serialize.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/25utf8.t b/t/basicrels/25utf8.t deleted file mode 100644 index c5fe364..0000000 --- a/t/basicrels/25utf8.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/25utf8.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/26might_have.t b/t/basicrels/26might_have.t deleted file mode 100644 index f2942e4..0000000 --- a/t/basicrels/26might_have.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/26might_have.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/27ordered.t b/t/basicrels/27ordered.t deleted file mode 100644 index dc7c61e..0000000 --- a/t/basicrels/27ordered.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/27ordered.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/28result_set_column.t b/t/basicrels/28result_set_column.t deleted file mode 100644 index cff21d7..0000000 --- a/t/basicrels/28result_set_column.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/28result_set_column.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/29inflate_datetime.t b/t/basicrels/29inflate_datetime.t deleted file mode 100644 index 62fa6f5..0000000 --- a/t/basicrels/29inflate_datetime.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/29inflate_datetime.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/30ensure_class_loaded.t b/t/basicrels/30ensure_class_loaded.t deleted file mode 100644 index 67f2d6c..0000000 --- a/t/basicrels/30ensure_class_loaded.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/30ensure_class_loaded.tl"; -run_tests(DBICTest->schema); diff --git a/t/basicrels/30join_torture.t b/t/basicrels/30join_torture.t deleted file mode 100644 index 6bc0ca5..0000000 --- a/t/basicrels/30join_torture.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::BasicRels; - -require "t/run/30join_torture.tl"; -run_tests(DBICTest->schema); diff --git a/t/cdbi-sweet-t/08pager.t b/t/cdbi-sweet-t/08pager.t index 9650315..e105932 100644 --- a/t/cdbi-sweet-t/08pager.t +++ b/t/cdbi-sweet-t/08pager.t @@ -15,7 +15,8 @@ BEGIN { use lib 't/lib'; -use_ok('DBICTest::HelperRels'); +use_ok('DBICTest'); +DBICTest::init_schema(); DBICTest::CD->load_components(qw/CDBICompat::Pager/); diff --git a/t/helperrels/01core.t b/t/helperrels/01core.t deleted file mode 100644 index 1829aef..0000000 --- a/t/helperrels/01core.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/01core.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/04db.t b/t/helperrels/04db.t deleted file mode 100644 index 5051ac3..0000000 --- a/t/helperrels/04db.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/04db.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/05multipk.t b/t/helperrels/05multipk.t deleted file mode 100644 index fc5b046..0000000 --- a/t/helperrels/05multipk.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/05multipk.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/06relationship.t b/t/helperrels/06relationship.t deleted file mode 100644 index c56d936..0000000 --- a/t/helperrels/06relationship.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/06relationship.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/07pager.t b/t/helperrels/07pager.t deleted file mode 100644 index a0b192f..0000000 --- a/t/helperrels/07pager.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/07pager.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/08inflate.t b/t/helperrels/08inflate.t deleted file mode 100644 index 9f1afb5..0000000 --- a/t/helperrels/08inflate.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/08inflate.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/08inflate_has_a.t b/t/helperrels/08inflate_has_a.t deleted file mode 100644 index 32641eb..0000000 --- a/t/helperrels/08inflate_has_a.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/08inflate_has_a.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/08inflate_serialize.t b/t/helperrels/08inflate_serialize.t deleted file mode 100644 index e0ca1d8..0000000 --- a/t/helperrels/08inflate_serialize.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/08inflate_serialize.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/09update.t b/t/helperrels/09update.t deleted file mode 100644 index 05cc63e..0000000 --- a/t/helperrels/09update.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/09update.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/10auto.t b/t/helperrels/10auto.t deleted file mode 100644 index 94c0c7c..0000000 --- a/t/helperrels/10auto.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/10auto.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/11mysql.t b/t/helperrels/11mysql.t deleted file mode 100644 index 397f961..0000000 --- a/t/helperrels/11mysql.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/11mysql.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/12pg.t b/t/helperrels/12pg.t deleted file mode 100644 index 281289d..0000000 --- a/t/helperrels/12pg.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/12pg.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/13oracle.t b/t/helperrels/13oracle.t deleted file mode 100644 index 25a6e51..0000000 --- a/t/helperrels/13oracle.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/13oracle.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/145db2.t b/t/helperrels/145db2.t deleted file mode 100644 index c6925ef..0000000 --- a/t/helperrels/145db2.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/145db2.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/146db2_400.t b/t/helperrels/146db2_400.t deleted file mode 100644 index 655bc05..0000000 --- a/t/helperrels/146db2_400.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/146db2_400.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/14mssql.t b/t/helperrels/14mssql.t deleted file mode 100644 index b43847f..0000000 --- a/t/helperrels/14mssql.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/14mssql.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/15limit.t b/t/helperrels/15limit.t deleted file mode 100644 index fa22b73..0000000 --- a/t/helperrels/15limit.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/15limit.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/16joins.t b/t/helperrels/16joins.t deleted file mode 100644 index bf451e9..0000000 --- a/t/helperrels/16joins.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/16joins.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/17join_count.t b/t/helperrels/17join_count.t deleted file mode 100644 index 531d9ff..0000000 --- a/t/helperrels/17join_count.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/17join_count.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/18self_referencial.t b/t/helperrels/18self_referencial.t deleted file mode 100644 index 6cec715..0000000 --- a/t/helperrels/18self_referencial.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/18self_referencial.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/19uuid.t b/t/helperrels/19uuid.t deleted file mode 100644 index 2d0d4cb..0000000 --- a/t/helperrels/19uuid.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/19uuid.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/20unique.t b/t/helperrels/20unique.t deleted file mode 100644 index 91eed2c..0000000 --- a/t/helperrels/20unique.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/20unique.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/21transactions.t b/t/helperrels/21transactions.t deleted file mode 100644 index 5730483..0000000 --- a/t/helperrels/21transactions.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/21transactions.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/22cascade_copy.t b/t/helperrels/22cascade_copy.t deleted file mode 100644 index bc124e1..0000000 --- a/t/helperrels/22cascade_copy.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/22cascade_copy.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/23cache.t b/t/helperrels/23cache.t deleted file mode 100644 index 73bc31a..0000000 --- a/t/helperrels/23cache.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/23cache.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/24serialize.t b/t/helperrels/24serialize.t deleted file mode 100644 index bc51393..0000000 --- a/t/helperrels/24serialize.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/24serialize.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/25utf8.t b/t/helperrels/25utf8.t deleted file mode 100644 index ad3fe14..0000000 --- a/t/helperrels/25utf8.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/25utf8.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/26might_have.t b/t/helperrels/26might_have.t deleted file mode 100644 index d3ec615..0000000 --- a/t/helperrels/26might_have.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/26might_have.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/27ordered.t b/t/helperrels/27ordered.t deleted file mode 100644 index 352a730..0000000 --- a/t/helperrels/27ordered.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/27ordered.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/28result_set_column.t b/t/helperrels/28result_set_column.t deleted file mode 100644 index 105b5c7..0000000 --- a/t/helperrels/28result_set_column.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/28result_set_column.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/29dbicadmin.t b/t/helperrels/29dbicadmin.t deleted file mode 100644 index ea5882e..0000000 --- a/t/helperrels/29dbicadmin.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/29dbicadmin.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/29inflate_datetime.t b/t/helperrels/29inflate_datetime.t deleted file mode 100644 index aacf84a..0000000 --- a/t/helperrels/29inflate_datetime.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/29inflate_datetime.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/30ensure_class_loaded.t b/t/helperrels/30ensure_class_loaded.t deleted file mode 100644 index 6edbe80..0000000 --- a/t/helperrels/30ensure_class_loaded.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/30ensure_class_loaded.tl"; -run_tests(DBICTest->schema); diff --git a/t/helperrels/30join_torture.t b/t/helperrels/30join_torture.t deleted file mode 100644 index 1e85aeb..0000000 --- a/t/helperrels/30join_torture.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::HelperRels; - -require "t/run/30join_torture.tl"; -run_tests(DBICTest->schema); diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index af058be..9dbbf55 100755 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -4,25 +4,234 @@ package # hide from PAUSE use strict; use warnings; use DBICTest::Schema; -use DBICTest::Schema::Relationships; + +=head1 NAME + +DBICTest - Library to be used by DBIx::Class test scripts. + +=head1 SYNOPSIS + + use lib qw(t/lib); + use DBICTest; + use Test::More; + + my $schema = DBICTest->init_schema(); + +=head1 DESCRIPTION + +This module provides the basic utilities to write tests against +DBIx::Class. + +=head1 METHODS + +=head2 init_schema + + my $schema = DBICTest->init_schema( + no_deploy=>1, + no_populate=>1, + ); + +This method removes the test SQLite database in t/var/DBIxClass.db +and then creates a new, empty database. + +This method will call deploy_schema() by default, unless the +no_deploy flag is set. + +Also, by default, this method will call populate_schema() by +default, unless the no_deploy or no_populate flags are set. + +=cut sub init_schema { + my $self = shift; + my %args = @_; + my $db_file = "t/var/DBIxClass.db"; + + unlink($db_file) if -e $db_file; + unlink($db_file . "-journal") if -e $db_file . "-journal"; + mkdir("t/var") unless -d "t/var"; + + my $dsn = $ENV{"DBICTEST_DSN"} || "dbi:SQLite:${db_file}"; + my $dbuser = $ENV{"DBICTEST_DBUSER"} || ''; + my $dbpass = $ENV{"DBICTEST_DBPASS"} || ''; + + my $schema = DBICTest::Schema->compose_connection('DBICTest' => $dsn, $dbuser, $dbpass); + if ( !$args{no_deploy} ) { + __PACKAGE__->deploy_schema( $schema ); + __PACKAGE__->populate_schema( $schema ) if( !$args{no_populate} ); + } + return $schema; +} + +=head2 deploy_schema + + DBICTest->deploy_schema( $schema ); + +This method does one of two things to the schema. It can either call +the experimental $schema->deploy() if the DBICTEST_SQLT_DEPLOY environment +variable is set, otherwise the default is to read in the t/lib/sqlite.sql +file and execute the SQL within. Either way you end up with a fresh set +of tables for testing. + +=cut + +sub deploy_schema { + my $self = shift; + my $schema = shift; + + if ($ENV{"DBICTEST_SQLT_DEPLOY"}) { + return $schema->deploy(); + } else { + open IN, "t/lib/sqlite.sql"; + my $sql; + { local $/ = undef; $sql = ; } + close IN; + $schema->storage->dbh->do($_) for split(/;\n/, $sql); + } +} + +=head2 populate_schema + + DBICTest->populate_schema( $schema ); + +After you deploy your schema you can use this method to populate +the tables with test data. + +=cut + +sub populate_schema { + my $self = shift; + my $schema = shift; + + $schema->storage->dbh->do("PRAGMA synchronous = OFF"); + + $schema->populate('Artist', [ + [ qw/artistid name/ ], + [ 1, 'Caterwauler McCrae' ], + [ 2, 'Random Boy Band' ], + [ 3, 'We Are Goth' ], + ]); + + $schema->populate('CD', [ + [ qw/cdid artist title year/ ], + [ 1, 1, "Spoonful of bees", 1999 ], + [ 2, 1, "Forkful of bees", 2001 ], + [ 3, 1, "Caterwaulin' Blues", 1997 ], + [ 4, 2, "Generic Manufactured Singles", 2001 ], + [ 5, 3, "Come Be Depressed With Us", 1998 ], + ]); + + $schema->populate('LinerNotes', [ + [ qw/liner_id notes/ ], + [ 2, "Buy Whiskey!" ], + [ 4, "Buy Merch!" ], + [ 5, "Kill Yourself!" ], + ]); + + $schema->populate('Tag', [ + [ qw/tagid cd tag/ ], + [ 1, 1, "Blue" ], + [ 2, 2, "Blue" ], + [ 3, 3, "Blue" ], + [ 4, 5, "Blue" ], + [ 5, 2, "Cheesy" ], + [ 6, 4, "Cheesy" ], + [ 7, 5, "Cheesy" ], + [ 8, 2, "Shiny" ], + [ 9, 4, "Shiny" ], + ]); + + $schema->populate('TwoKeys', [ + [ qw/artist cd/ ], + [ 1, 1 ], + [ 1, 2 ], + [ 2, 2 ], + ]); + + $schema->populate('FourKeys', [ + [ qw/foo bar hello goodbye/ ], + [ 1, 2, 3, 4 ], + [ 5, 4, 3, 6 ], + ]); + + $schema->populate('OneKey', [ + [ qw/id artist cd/ ], + [ 1, 1, 1 ], + [ 2, 1, 2 ], + [ 3, 2, 2 ], + ]); + + $schema->populate('SelfRef', [ + [ qw/id name/ ], + [ 1, 'First' ], + [ 2, 'Second' ], + ]); + + $schema->populate('SelfRefAlias', [ + [ qw/self_ref alias/ ], + [ 1, 2 ] + ]); + + $schema->populate('ArtistUndirectedMap', [ + [ qw/id1 id2/ ], + [ 1, 2 ] + ]); + + $schema->populate('Producer', [ + [ qw/producerid name/ ], + [ 1, 'Matt S Trout' ], + [ 2, 'Bob The Builder' ], + [ 3, 'Fred The Phenotype' ], + ]); + + $schema->populate('CD_to_Producer', [ + [ qw/cd producer/ ], + [ 1, 1 ], + [ 1, 2 ], + [ 1, 3 ], + ]); - my $db_file = "t/var/DBIxClass.db"; + $schema->populate('TreeLike', [ + [ qw/id parent name/ ], + [ 1, 0, 'foo' ], + [ 2, 1, 'bar' ], + [ 3, 2, 'baz' ], + [ 4, 3, 'quux' ], + ]); - unlink($db_file) if -e $db_file; - unlink($db_file . "-journal") if -e $db_file . "-journal"; - mkdir("t/var") unless -d "t/var"; + $schema->populate('Track', [ + [ qw/trackid cd position title/ ], + [ 4, 2, 1, "Stung with Success"], + [ 5, 2, 2, "Stripy"], + [ 6, 2, 3, "Sticky Honey"], + [ 7, 3, 1, "Yowlin"], + [ 8, 3, 2, "Howlin"], + [ 9, 3, 3, "Fowlin"], + [ 10, 4, 1, "Boring Name"], + [ 11, 4, 2, "Boring Song"], + [ 12, 4, 3, "No More Ideas"], + [ 13, 5, 1, "Sad"], + [ 14, 5, 2, "Under The Weather"], + [ 15, 5, 3, "Suicidal"], + [ 16, 1, 1, "The Bees Knees"], + [ 17, 1, 2, "Apiary"], + [ 18, 1, 3, "Beehind You"], + ]); - my $dsn = $ENV{"DBICTEST_DSN"} || "dbi:SQLite:${db_file}"; - my $dbuser = $ENV{"DBICTEST_DBUSER"} || ''; - my $dbpass = $ENV{"DBICTEST_DBPASS"} || ''; + $schema->populate('Event', [ + [ qw/id starts_at/ ], + [ 1, '2006-04-25 22:24:33' ], + ]); - my $schema = DBICTest::Schema->compose_connection('DBICTest' => $dsn, $dbuser, $dbpass); - $schema->deploy(); - $schema->auto_populate(); - return $schema; + $schema->populate('Link', [ + [ qw/id title/ ], + [ 1, 'aaa' ] + ]); + $schema->populate('Bookmark', [ + [ qw/id link/ ], + [ 1, 1 ] + ]); } 1; diff --git a/t/lib/DBICTest/Schema.pm b/t/lib/DBICTest/Schema.pm index aff1d00..1fd503c 100644 --- a/t/lib/DBICTest/Schema.pm +++ b/t/lib/DBICTest/Schema.pm @@ -35,147 +35,4 @@ __PACKAGE__->load_classes(qw/ qw/SelfRefAlias TreeLike TwoKeyTreeLike Event/ ); -sub deploy { - my $self = shift; - - if ($ENV{"DBICTEST_SQLT_DEPLOY"}) { - return $schema->next::method(@_); - } else { - open IN, "t/lib/sqlite.sql"; - my $sql; - { local $/ = undef; $sql = ; } - close IN; - $self->storage->dbh->do($_) for split(/;\n/, $sql); - } -} - -sub auto_populate { - my $self = shift; - - $self->storage->dbh->do("PRAGMA synchronous = OFF"); - - $self->populate('Artist', [ - [ qw/artistid name/ ], - [ 1, 'Caterwauler McCrae' ], - [ 2, 'Random Boy Band' ], - [ 3, 'We Are Goth' ], - ]); - - $self->populate('CD', [ - [ qw/cdid artist title year/ ], - [ 1, 1, "Spoonful of bees", 1999 ], - [ 2, 1, "Forkful of bees", 2001 ], - [ 3, 1, "Caterwaulin' Blues", 1997 ], - [ 4, 2, "Generic Manufactured Singles", 2001 ], - [ 5, 3, "Come Be Depressed With Us", 1998 ], - ]); - - $self->populate('LinerNotes', [ - [ qw/liner_id notes/ ], - [ 2, "Buy Whiskey!" ], - [ 4, "Buy Merch!" ], - [ 5, "Kill Yourself!" ], - ]); - - $self->populate('Tag', [ - [ qw/tagid cd tag/ ], - [ 1, 1, "Blue" ], - [ 2, 2, "Blue" ], - [ 3, 3, "Blue" ], - [ 4, 5, "Blue" ], - [ 5, 2, "Cheesy" ], - [ 6, 4, "Cheesy" ], - [ 7, 5, "Cheesy" ], - [ 8, 2, "Shiny" ], - [ 9, 4, "Shiny" ], - ]); - - $self->populate('TwoKeys', [ - [ qw/artist cd/ ], - [ 1, 1 ], - [ 1, 2 ], - [ 2, 2 ], - ]); - - $self->populate('FourKeys', [ - [ qw/foo bar hello goodbye/ ], - [ 1, 2, 3, 4 ], - [ 5, 4, 3, 6 ], - ]); - - $self->populate('OneKey', [ - [ qw/id artist cd/ ], - [ 1, 1, 1 ], - [ 2, 1, 2 ], - [ 3, 2, 2 ], - ]); - - $self->populate('SelfRef', [ - [ qw/id name/ ], - [ 1, 'First' ], - [ 2, 'Second' ], - ]); - - $self->populate('SelfRefAlias', [ - [ qw/self_ref alias/ ], - [ 1, 2 ] - ]); - - $self->populate('ArtistUndirectedMap', [ - [ qw/id1 id2/ ], - [ 1, 2 ] - ]); - - $self->populate('Producer', [ - [ qw/producerid name/ ], - [ 1, 'Matt S Trout' ], - [ 2, 'Bob The Builder' ], - [ 3, 'Fred The Phenotype' ], - ]); - - $self->populate('CD_to_Producer', [ - [ qw/cd producer/ ], - [ 1, 1 ], - [ 1, 2 ], - [ 1, 3 ], - ]); - - $self->populate('TreeLike', [ - [ qw/id parent name/ ], - [ 1, 0, 'foo' ], - [ 2, 1, 'bar' ], - [ 3, 2, 'baz' ], - [ 4, 3, 'quux' ], - ]); - - $self->populate('Track', [ - [ qw/trackid cd position title/ ], - [ 4, 2, 1, "Stung with Success"], - [ 5, 2, 2, "Stripy"], - [ 6, 2, 3, "Sticky Honey"], - [ 7, 3, 1, "Yowlin"], - [ 8, 3, 2, "Howlin"], - [ 9, 3, 3, "Fowlin"], - [ 10, 4, 1, "Boring Name"], - [ 11, 4, 2, "Boring Song"], - [ 12, 4, 3, "No More Ideas"], - [ 13, 5, 1, "Sad"], - [ 14, 5, 2, "Under The Weather"], - [ 15, 5, 3, "Suicidal"], - [ 16, 1, 1, "The Bees Knees"], - [ 17, 1, 2, "Apiary"], - [ 18, 1, 3, "Beehind You"], - ]); - - $self->populate('Link', [ - [ qw/id title/ ], - [ 1, 'aaa' ] - ]); - - $self->populate('Bookmark', [ - [ qw/id link/ ], - [ 1, 1 ] - ]); -} - 1; diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index f4c6706..0bb49c4 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -3,10 +3,8 @@ package # hide from PAUSE use base 'DBIx::Class::Core'; -__PACKAGE__->load_components('PK::Auto'); - -DBICTest::Schema::Artist->table('artist'); -DBICTest::Schema::Artist->add_columns( +__PACKAGE__->table('artist'); +__PACKAGE__->add_columns( 'artistid' => { data_type => 'integer', is_auto_increment => 1 @@ -17,11 +15,25 @@ DBICTest::Schema::Artist->add_columns( is_nullable => 1, }, ); -DBICTest::Schema::Artist->set_primary_key('artistid'); +__PACKAGE__->set_primary_key('artistid'); __PACKAGE__->mk_classdata('field_name_for', { artistid => 'primary key', name => 'artist name', }); +__PACKAGE__->has_many( + cds => 'DBICTest::Schema::CD', undef, + { order_by => 'year' }, +); + +__PACKAGE__->has_many( twokeys => 'DBICTest::Schema::TwoKeys' ); +__PACKAGE__->has_many( onekeys => 'DBICTest::Schema::OneKey' ); + +__PACKAGE__->has_many( + artist_undirected_maps => 'DBICTest::Schema::ArtistUndirectedMap', + [ {'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'} ], + { cascade_copy => 0 } # this would *so* not make sense +); + 1; diff --git a/t/lib/DBICTest/Schema/ArtistUndirectedMap.pm b/t/lib/DBICTest/Schema/ArtistUndirectedMap.pm index 6e888ed..2669575 100644 --- a/t/lib/DBICTest/Schema/ArtistUndirectedMap.pm +++ b/t/lib/DBICTest/Schema/ArtistUndirectedMap.pm @@ -10,4 +10,11 @@ __PACKAGE__->add_columns( ); __PACKAGE__->set_primary_key(qw/id1 id2/); +__PACKAGE__->belongs_to( 'artist1', 'DBICTest::Schema::Artist', 'id1' ); +__PACKAGE__->belongs_to( 'artist2', 'DBICTest::Schema::Artist', 'id2'); +__PACKAGE__->has_many( + 'mapped_artists', 'DBICTest::Schema::Artist', + [ {'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'} ], +); + 1; diff --git a/t/lib/DBICTest/Schema/Bookmark.pm b/t/lib/DBICTest/Schema/Bookmark.pm index 4f9ec44..72db586 100644 --- a/t/lib/DBICTest/Schema/Bookmark.pm +++ b/t/lib/DBICTest/Schema/Bookmark.pm @@ -7,7 +7,6 @@ package # hide from PAUSE use strict; use warnings; -__PACKAGE__->load_components(qw/PK::Auto Core/); __PACKAGE__->table('bookmark'); __PACKAGE__->add_columns(qw/id link/); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/CD.pm b/t/lib/DBICTest/Schema/CD.pm index 90e4c0c..262d23f 100644 --- a/t/lib/DBICTest/Schema/CD.pm +++ b/t/lib/DBICTest/Schema/CD.pm @@ -3,10 +3,8 @@ package # hide from PAUSE use base 'DBIx::Class::Core'; -__PACKAGE__->load_components('PK::Auto'); - -DBICTest::Schema::CD->table('cd'); -DBICTest::Schema::CD->add_columns( +__PACKAGE__->table('cd'); +__PACKAGE__->add_columns( 'cdid' => { data_type => 'integer', is_auto_increment => 1, @@ -23,7 +21,28 @@ DBICTest::Schema::CD->add_columns( size => 100, }, ); -DBICTest::Schema::CD->set_primary_key('cdid'); -DBICTest::Schema::CD->add_unique_constraint(artist_title => [ qw/artist title/ ]); +__PACKAGE__->set_primary_key('cdid'); +__PACKAGE__->add_unique_constraint(artist_title => [ qw/artist title/ ]); + +__PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist' ); + +__PACKAGE__->has_many( tracks => 'DBICTest::Schema::Track' ); +__PACKAGE__->has_many( + tags => 'DBICTest::Schema::Tag', undef, + { order_by => 'tag' }, +); +__PACKAGE__->has_many( + cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd' +); + +__PACKAGE__->might_have( + liner_notes => 'DBICTest::Schema::LinerNotes', undef, + { proxy => [ qw/notes/ ] }, +); +__PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' ); +__PACKAGE__->many_to_many( + producers_sorted => cd_to_producer => 'producer', + { order_by => 'producer.name' }, +); 1; diff --git a/t/lib/DBICTest/Schema/CD_to_Producer.pm b/t/lib/DBICTest/Schema/CD_to_Producer.pm index 378c58c..117a590 100644 --- a/t/lib/DBICTest/Schema/CD_to_Producer.pm +++ b/t/lib/DBICTest/Schema/CD_to_Producer.pm @@ -10,4 +10,14 @@ __PACKAGE__->add_columns( ); __PACKAGE__->set_primary_key(qw/cd producer/); +__PACKAGE__->belongs_to( + 'cd', 'DBICTest::Schema::CD', + { 'foreign.cdid' => 'self.cd' } +); + +__PACKAGE__->belongs_to( + 'producer', 'DBICTest::Schema::Producer', + { 'foreign.producerid' => 'self.producer' } +); + 1; diff --git a/t/lib/DBICTest/Schema/Employee.pm b/t/lib/DBICTest/Schema/Employee.pm index e91f872..78b3d16 100644 --- a/t/lib/DBICTest/Schema/Employee.pm +++ b/t/lib/DBICTest/Schema/Employee.pm @@ -1,9 +1,9 @@ package # hide from PAUSE DBICTest::Schema::Employee; -use base 'DBIx::Class'; +use base 'DBIx::Class::Core'; -__PACKAGE__->load_components(qw( Ordered PK::Auto Core )); +__PACKAGE__->load_components(qw( Ordered )); __PACKAGE__->table('employee'); diff --git a/t/lib/DBICTest/Schema/Event.pm b/t/lib/DBICTest/Schema/Event.pm index fea3b07..937d782 100644 --- a/t/lib/DBICTest/Schema/Event.pm +++ b/t/lib/DBICTest/Schema/Event.pm @@ -2,9 +2,9 @@ package DBICTest::Schema::Event; use strict; use warnings; -use base qw/DBIx::Class/; +use base qw/DBIx::Class::Core/; -__PACKAGE__->load_components(qw/InflateColumn::DateTime PK::Auto Core/); +__PACKAGE__->load_components(qw/InflateColumn::DateTime/); __PACKAGE__->table('event'); diff --git a/t/lib/DBICTest/Schema/Link.pm b/t/lib/DBICTest/Schema/Link.pm index 72574ea..5343122 100644 --- a/t/lib/DBICTest/Schema/Link.pm +++ b/t/lib/DBICTest/Schema/Link.pm @@ -6,7 +6,6 @@ use base 'DBIx::Class::Core'; use strict; use warnings; -__PACKAGE__->load_components(qw/PK::Auto Core/); __PACKAGE__->table('link'); __PACKAGE__->add_columns( 'id' => { diff --git a/t/lib/DBICTest/Schema/OneKey.pm b/t/lib/DBICTest/Schema/OneKey.pm index dbe7003..4cc2918 100644 --- a/t/lib/DBICTest/Schema/OneKey.pm +++ b/t/lib/DBICTest/Schema/OneKey.pm @@ -3,8 +3,6 @@ package # hide from PAUSE use base 'DBIx::Class::Core'; -__PACKAGE__->load_components('PK::Auto'); - DBICTest::Schema::OneKey->table('onekey'); DBICTest::Schema::OneKey->add_columns( 'id' => { diff --git a/t/lib/DBICTest/Schema/Relationships.pm b/t/lib/DBICTest/Schema/Relationships.pm deleted file mode 100644 index a199c88..0000000 --- a/t/lib/DBICTest/Schema/Relationships.pm +++ /dev/null @@ -1,62 +0,0 @@ -package # hide from PAUSE - DBICTest::Schema::Relationships; - -use base 'DBIx::Class::Core'; - -DBICTest::Schema::Artist->has_many(cds => 'DBICTest::Schema::CD', undef, - { order_by => 'year' }); -DBICTest::Schema::Artist->has_many(twokeys => 'DBICTest::Schema::TwoKeys'); -DBICTest::Schema::Artist->has_many(onekeys => 'DBICTest::Schema::OneKey'); - -DBICTest::Schema::CD->belongs_to('artist', 'DBICTest::Schema::Artist'); - -DBICTest::Schema::CD->has_many(tracks => 'DBICTest::Schema::Track'); -DBICTest::Schema::CD->has_many(tags => 'DBICTest::Schema::Tag', undef, - { order_by => 'tag' }); -DBICTest::Schema::CD->has_many(cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd'); - -DBICTest::Schema::CD->might_have(liner_notes => 'DBICTest::Schema::LinerNotes', - undef, { proxy => [ qw/notes/ ] }); - -DBICTest::Schema::SelfRefAlias->belongs_to( - self_ref => 'DBICTest::Schema::SelfRef'); -DBICTest::Schema::SelfRefAlias->belongs_to( - alias => 'DBICTest::Schema::SelfRef'); - -DBICTest::Schema::SelfRef->has_many( - aliases => 'DBICTest::Schema::SelfRefAlias' => 'self_ref'); - -DBICTest::Schema::Tag->belongs_to('cd', 'DBICTest::Schema::CD'); - -DBICTest::Schema::Track->belongs_to('cd', 'DBICTest::Schema::CD'); -DBICTest::Schema::Track->belongs_to('disc', 'DBICTest::Schema::CD', 'cd'); - -DBICTest::Schema::TwoKeys->belongs_to('artist', 'DBICTest::Schema::Artist'); -DBICTest::Schema::TwoKeys->belongs_to('cd', 'DBICTest::Schema::CD'); - -DBICTest::Schema::CD_to_Producer->belongs_to( - 'cd', 'DBICTest::Schema::CD', - { 'foreign.cdid' => 'self.cd' } -); -DBICTest::Schema::CD_to_Producer->belongs_to( - 'producer', 'DBICTest::Schema::Producer', - { 'foreign.producerid' => 'self.producer' } -); -DBICTest::Schema::Artist->has_many( - 'artist_undirected_maps', 'DBICTest::Schema::ArtistUndirectedMap', - [{'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'}], - { cascade_copy => 0 } # this would *so* not make sense -); -DBICTest::Schema::ArtistUndirectedMap->belongs_to( - 'artist1', 'DBICTest::Schema::Artist', 'id1'); -DBICTest::Schema::ArtistUndirectedMap->belongs_to( - 'artist2', 'DBICTest::Schema::Artist', 'id2'); -DBICTest::Schema::ArtistUndirectedMap->has_many( - 'mapped_artists', 'DBICTest::Schema::Artist', - [{'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'}]); - -# now the Helpers -DBICTest::Schema::CD->many_to_many( 'producers', 'cd_to_producer', 'producer'); -DBICTest::Schema::CD->many_to_many( 'producers_sorted', 'cd_to_producer', 'producer', { order_by => 'producer.name' }); - -1; diff --git a/t/lib/DBICTest/Schema/SelfRef.pm b/t/lib/DBICTest/Schema/SelfRef.pm index 474c1a2..ec715c7 100644 --- a/t/lib/DBICTest/Schema/SelfRef.pm +++ b/t/lib/DBICTest/Schema/SelfRef.pm @@ -16,4 +16,6 @@ __PACKAGE__->add_columns( ); __PACKAGE__->set_primary_key('id'); +__PACKAGE__->has_many( aliases => 'DBICTest::Schema::SelfRefAlias' => 'self_ref' ); + 1; diff --git a/t/lib/DBICTest/Schema/SelfRefAlias.pm b/t/lib/DBICTest/Schema/SelfRefAlias.pm index 9d58a8c..e7ed491 100644 --- a/t/lib/DBICTest/Schema/SelfRefAlias.pm +++ b/t/lib/DBICTest/Schema/SelfRefAlias.pm @@ -14,4 +14,7 @@ __PACKAGE__->add_columns( ); __PACKAGE__->set_primary_key(qw/self_ref alias/); +__PACKAGE__->belongs_to( self_ref => 'DBICTest::Schema::SelfRef' ); +__PACKAGE__->belongs_to( alias => 'DBICTest::Schema::SelfRef' ); + 1; diff --git a/t/lib/DBICTest/Schema/Tag.pm b/t/lib/DBICTest/Schema/Tag.pm index b93b622..b75c2ef 100644 --- a/t/lib/DBICTest/Schema/Tag.pm +++ b/t/lib/DBICTest/Schema/Tag.pm @@ -3,10 +3,8 @@ package # hide from PAUSE use base qw/DBIx::Class::Core/; -__PACKAGE__->load_components('PK::Auto'); - -DBICTest::Schema::Tag->table('tags'); -DBICTest::Schema::Tag->add_columns( +__PACKAGE__->table('tags'); +__PACKAGE__->add_columns( 'tagid' => { data_type => 'integer', is_auto_increment => 1, @@ -19,6 +17,8 @@ DBICTest::Schema::Tag->add_columns( size => 100, }, ); -DBICTest::Schema::Tag->set_primary_key('tagid'); +__PACKAGE__->set_primary_key('tagid'); + +__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD' ); 1; diff --git a/t/lib/DBICTest/Schema/Track.pm b/t/lib/DBICTest/Schema/Track.pm index 9bbefff..691974a 100644 --- a/t/lib/DBICTest/Schema/Track.pm +++ b/t/lib/DBICTest/Schema/Track.pm @@ -3,8 +3,8 @@ package # hide from PAUSE use base 'DBIx::Class::Core'; -DBICTest::Schema::Track->table('track'); -DBICTest::Schema::Track->add_columns( +__PACKAGE__->table('track'); +__PACKAGE__->add_columns( 'trackid' => { data_type => 'integer', is_auto_increment => 1, @@ -21,6 +21,9 @@ DBICTest::Schema::Track->add_columns( size => 100, }, ); -DBICTest::Schema::Track->set_primary_key('trackid'); +__PACKAGE__->set_primary_key('trackid'); + +__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD' ); +__PACKAGE__->belongs_to( disc => 'DBICTest::Schema::CD' => 'cd'); 1; diff --git a/t/lib/DBICTest/Schema/TreeLike.pm b/t/lib/DBICTest/Schema/TreeLike.pm index 1eca3e1..73f9143 100644 --- a/t/lib/DBICTest/Schema/TreeLike.pm +++ b/t/lib/DBICTest/Schema/TreeLike.pm @@ -1,9 +1,7 @@ package # hide from PAUSE DBICTest::Schema::TreeLike; -use base qw/DBIx::Class/; - -__PACKAGE__->load_components(qw/PK::Auto::SQLite Core/); +use base qw/DBIx::Class::Core/; __PACKAGE__->table('treelike'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/TwoKeyTreeLike.pm b/t/lib/DBICTest/Schema/TwoKeyTreeLike.pm index c7258e0..1c1b7b9 100644 --- a/t/lib/DBICTest/Schema/TwoKeyTreeLike.pm +++ b/t/lib/DBICTest/Schema/TwoKeyTreeLike.pm @@ -1,9 +1,7 @@ package # hide from PAUSE DBICTest::Schema::TwoKeyTreeLike; -use base qw/DBIx::Class/; - -__PACKAGE__->load_components(qw/Core/); +use base qw/DBIx::Class::Core/; __PACKAGE__->table('twokeytreelike'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/TwoKeys.pm b/t/lib/DBICTest/Schema/TwoKeys.pm index 91a6fef..8483d0b 100755 --- a/t/lib/DBICTest/Schema/TwoKeys.pm +++ b/t/lib/DBICTest/Schema/TwoKeys.pm @@ -3,11 +3,14 @@ package # hide from PAUSE use base 'DBIx::Class::Core'; -DBICTest::Schema::TwoKeys->table('twokeys'); -DBICTest::Schema::TwoKeys->add_columns( +__PACKAGE__->table('twokeys'); +__PACKAGE__->add_columns( 'artist' => { data_type => 'integer' }, 'cd' => { data_type => 'integer' }, ); -DBICTest::Schema::TwoKeys->set_primary_key(qw/artist cd/); +__PACKAGE__->set_primary_key(qw/artist cd/); + +__PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist' ); +__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD' ); 1; diff --git a/t/lib/DBICTest/Setup.pm b/t/lib/DBICTest/Setup.pm deleted file mode 100755 index 833bebf..0000000 --- a/t/lib/DBICTest/Setup.pm +++ /dev/null @@ -1,155 +0,0 @@ -use strict; -use warnings; -use DBICTest; - -my $schema = DBICTest->initialise; - -# $schema->storage->on_connect_do([ "PRAGMA synchronous = OFF" ]); - -my $dbh = $schema->storage->dbh; - -if ($ENV{"DBICTEST_SQLT_DEPLOY"}) { - $schema->deploy; -} else { - open IN, "t/lib/sqlite.sql"; - - my $sql; - - { local $/ = undef; $sql = ; } - - close IN; - - $dbh->do($_) for split(/;\n/, $sql); -} - -$schema->storage->dbh->do("PRAGMA synchronous = OFF"); - -$schema->populate('Artist', [ - [ qw/artistid name/ ], - [ 1, 'Caterwauler McCrae' ], - [ 2, 'Random Boy Band' ], - [ 3, 'We Are Goth' ], -]); - -$schema->populate('CD', [ - [ qw/cdid artist title year/ ], - [ 1, 1, "Spoonful of bees", 1999 ], - [ 2, 1, "Forkful of bees", 2001 ], - [ 3, 1, "Caterwaulin' Blues", 1997 ], - [ 4, 2, "Generic Manufactured Singles", 2001 ], - [ 5, 3, "Come Be Depressed With Us", 1998 ], -]); - -$schema->populate('LinerNotes', [ - [ qw/liner_id notes/ ], - [ 2, "Buy Whiskey!" ], - [ 4, "Buy Merch!" ], - [ 5, "Kill Yourself!" ], -]); - -$schema->populate('Tag', [ - [ qw/tagid cd tag/ ], - [ 1, 1, "Blue" ], - [ 2, 2, "Blue" ], - [ 3, 3, "Blue" ], - [ 4, 5, "Blue" ], - [ 5, 2, "Cheesy" ], - [ 6, 4, "Cheesy" ], - [ 7, 5, "Cheesy" ], - [ 8, 2, "Shiny" ], - [ 9, 4, "Shiny" ], -]); - -$schema->populate('TwoKeys', [ - [ qw/artist cd/ ], - [ 1, 1 ], - [ 1, 2 ], - [ 2, 2 ], -]); - -$schema->populate('FourKeys', [ - [ qw/foo bar hello goodbye/ ], - [ 1, 2, 3, 4 ], - [ 5, 4, 3, 6 ], -]); - -$schema->populate('OneKey', [ - [ qw/id artist cd/ ], - [ 1, 1, 1 ], - [ 2, 1, 2 ], - [ 3, 2, 2 ], -]); - -$schema->populate('SelfRef', [ - [ qw/id name/ ], - [ 1, 'First' ], - [ 2, 'Second' ], -]); - -$schema->populate('SelfRefAlias', [ - [ qw/self_ref alias/ ], - [ 1, 2 ] -]); - -$schema->populate('ArtistUndirectedMap', [ - [ qw/id1 id2/ ], - [ 1, 2 ] -]); - -$schema->populate('Producer', [ - [ qw/producerid name/ ], - [ 1, 'Matt S Trout' ], - [ 2, 'Bob The Builder' ], - [ 3, 'Fred The Phenotype' ], -]); - -$schema->populate('CD_to_Producer', [ - [ qw/cd producer/ ], - [ 1, 1 ], - [ 1, 2 ], - [ 1, 3 ], -]); - -$schema->populate('TreeLike', [ - [ qw/id parent name/ ], - [ 1, 0, 'foo' ], - [ 2, 1, 'bar' ], - [ 3, 2, 'baz' ], - [ 4, 3, 'quux' ], -]); - -$schema->populate('Track', [ - [ qw/trackid cd position title/ ], - [ 4, 2, 1, "Stung with Success"], - [ 5, 2, 2, "Stripy"], - [ 6, 2, 3, "Sticky Honey"], - [ 7, 3, 1, "Yowlin"], - [ 8, 3, 2, "Howlin"], - [ 9, 3, 3, "Fowlin"], - [ 10, 4, 1, "Boring Name"], - [ 11, 4, 2, "Boring Song"], - [ 12, 4, 3, "No More Ideas"], - [ 13, 5, 1, "Sad"], - [ 14, 5, 2, "Under The Weather"], - [ 15, 5, 3, "Suicidal"], - [ 16, 1, 1, "The Bees Knees"], - [ 17, 1, 2, "Apiary"], - [ 18, 1, 3, "Beehind You"], -]); - -$schema->populate('Event', [ - [ qw/id starts_at/ ], - [ 1, '2006-04-25 22:24:33' ], -]); - -$schema->populate('Link', [ - [ qw/id title/ ], - [ 1, 'aaa' ] -]); - -$schema->populate('Bookmark', [ - [ qw/id link/ ], - [ 1, 1 ] -]); - -1; diff --git a/t/run/25utf8.tl b/t/run/25utf8.tl deleted file mode 100644 index 278dde4..0000000 --- a/t/run/25utf8.tl +++ /dev/null @@ -1,23 +0,0 @@ -sub run_tests { - my $schema = shift; - - eval 'use Encode ; 1' - or plan skip_all, 'Install Encode run this test'; - - plan tests => 2; - - DBICTest::Schema::Artist->load_components('UTF8Columns'); - DBICTest::Schema::Artist->utf8_columns('name'); - Class::C3->reinitialize(); - - my $artist = $schema->resultset("Artist")->create( { name => 'uni' } ); - ok( Encode::is_utf8( $artist->name ), 'got name with utf8 flag' ); - - my $utf8_char = 'uniuni'; - Encode::_utf8_on($utf8_char); - $artist->name($utf8_char); - ok( !Encode::is_utf8( $artist->{_column_data}->{name} ), - 'store utf8 less chars' ); -} - -1; diff --git a/t/run/29dbicadmin.tl b/t/run/29dbicadmin.tl deleted file mode 100644 index 93c42a1..0000000 --- a/t/run/29dbicadmin.tl +++ /dev/null @@ -1,38 +0,0 @@ -# vim: filetype=perl - -sub run_tests { - - eval 'require JSON'; - plan skip_all, 'Install JSON to run this test' if ($@); - - eval 'require Text::CSV_XS'; - if ($@) { - eval 'require Text::CSV_PP'; - plan skip_all, 'Install Text::CSV_XS or Text::CSV_PP to run this test' if ($@); - } - - plan tests => 5; - my $schema = shift; - - my $employees = $schema->resultset('Employee'); - my $cmd = qq|script/dbicadmin --schema=DBICTest::Schema --class=Employee --tlibs --connect='["dbi:SQLite:dbname=t/var/DBIxClass.db","",""]' --force --tlibs|; - - `$cmd --op=insert --set='{name:"Matt"}'`; - ok( ($employees->count()==1), 'insert count' ); - - my $employee = $employees->find(1); - ok( ($employee->name() eq 'Matt'), 'insert valid' ); - - `$cmd --op=update --set='{name:"Trout"}'`; - $employee = $employees->find(1); - ok( ($employee->name() eq 'Trout'), 'update' ); - - `$cmd --op=insert --set='{name:"Aran"}'`; - my $data = `$cmd --op=select --attrs='{order_by:"name"}'`; - ok( ($data=~/Aran.*Trout/s), 'select with attrs' ); - - `$cmd --op=delete --where='{name:"Trout"}'`; - ok( ($employees->count()==1), 'delete' ); -} - -1;