From: Aran Deltac Date: Thu, 18 May 2006 05:15:24 +0000 (+0000) Subject: Delete basicrels tests. Modify run tests to use new syntax. Remove helperrels test... X-Git-Tag: v0.07002~75^2~167^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=70350518bbb31e5ac22fb3cb73d3e17409fcd332;p=dbsrgits%2FDBIx-Class.git Delete basicrels tests. Modify run tests to use new syntax. Remove helperrels test wrappers. --- 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/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/helperrels/26sqlt.t b/t/helperrels/26sqlt.t index af87625..f457d55 100644 --- a/t/helperrels/26sqlt.t +++ b/t/helperrels/26sqlt.t @@ -1,7 +1,9 @@ +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 $@; diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index af058be..ca44f05 100755 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -7,7 +7,6 @@ use DBICTest::Schema; use DBICTest::Schema::Relationships; sub init_schema { - my $db_file = "t/var/DBIxClass.db"; unlink($db_file) if -e $db_file; @@ -22,7 +21,6 @@ sub init_schema { $schema->deploy(); $schema->auto_populate(); return $schema; - } 1; diff --git a/t/lib/DBICTest/Setup.pm b/t/lib/DBICTest/Setup.pm deleted file mode 100755 index b493cb6..0000000 --- a/t/lib/DBICTest/Setup.pm +++ /dev/null @@ -1,150 +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('Link', [ - [ qw/id title/ ], - [ 1, 'aaa' ] -]); - -$schema->populate('Bookmark', [ - [ qw/id link/ ], - [ 1, 1 ] -]); - -1; diff --git a/t/run/01core.tl b/t/run/01core.tl index 05e4dd3..ad34e54 100644 --- a/t/run/01core.tl +++ b/t/run/01core.tl @@ -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 => 58; @@ -80,7 +86,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'); @@ -270,6 +276,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/run/04db.tl index 4865d96..5208614 100644 --- a/t/run/04db.tl +++ b/t/run/04db.tl @@ -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/run/05multipk.tl index e60f006..5cea1fd 100644 --- a/t/run/05multipk.tl +++ b/t/run/05multipk.tl @@ -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/run/06relationship.tl index 78b857f..45ed343 100644 --- a/t/run/06relationship.tl +++ b/t/run/06relationship.tl @@ -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/run/07pager.tl index d864afa..85b1e8d 100644 --- a/t/run/07pager.tl +++ b/t/run/07pager.tl @@ -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/run/08inflate.tl index e21a6c6..3906a02 100644 --- a/t/run/08inflate.tl +++ b/t/run/08inflate.tl @@ -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/run/08inflate_has_a.tl index 50f78c4..266585a 100644 --- a/t/run/08inflate_has_a.tl +++ b/t/run/08inflate_has_a.tl @@ -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/run/08inflate_serialize.tl index ae5ca7a..b51f961 100644 --- a/t/run/08inflate_serialize.tl +++ b/t/run/08inflate_serialize.tl @@ -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/run/09update.tl index ff802f0..70d7038 100644 --- a/t/run/09update.tl +++ b/t/run/09update.tl @@ -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/run/10auto.tl index 7c795f4..b108369 100644 --- a/t/run/10auto.tl +++ b/t/run/10auto.tl @@ -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/run/11mysql.tl index 15664d9..93f45fd 100644 --- a/t/run/11mysql.tl +++ b/t/run/11mysql.tl @@ -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/run/12pg.tl index d71e39c..754a830 100644 --- a/t/run/12pg.tl +++ b/t/run/12pg.tl @@ -1,10 +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_PG_${_}" } qw/DSN USER PASS/}; #warn "$dsn $user $pass"; -plan skip_all, 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' +plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' . ' (note: creates and drops a table named artist!)' unless ($dsn && $user); plan tests => 4; @@ -58,6 +63,3 @@ is_deeply($type_info, $test_type_info, $dbh->do("DROP TABLE testschema.artist;"); $dbh->do("DROP SCHEMA testschema;"); -} - -1; diff --git a/t/run/13oracle.tl b/t/run/13oracle.tl index f38b767..c0489ff 100644 --- a/t/run/13oracle.tl +++ b/t/run/13oracle.tl @@ -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/run/145db2.tl index 31e3461..36e5e8c 100644 --- a/t/run/145db2.tl +++ b/t/run/145db2.tl @@ -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_${_}" } qw/DSN USER PASS/}; @@ -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/run/146db2_400.tl index ac6cd47..6c2344c 100644 --- a/t/run/146db2_400.tl +++ b/t/run/146db2_400.tl @@ -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/}; @@ -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/run/14mssql.tl index befc14d..f21d9e2 100644 --- a/t/run/14mssql.tl +++ b/t/run/14mssql.tl @@ -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_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; @@ -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/run/15limit.tl index eca720d..98d3b64 100644 --- a/t/run/15limit.tl +++ b/t/run/15limit.tl @@ -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/run/16joins.tl index 15603aa..63e0363 100644 --- a/t/run/16joins.tl +++ b/t/run/16joins.tl @@ -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; @@ -296,6 +302,3 @@ is($queries, 1, 'prefetch ran only 1 sql statement'); $schema->storage->debug(0); -} # end run_tests - -1; diff --git a/t/run/17join_count.tl b/t/run/17join_count.tl index 08335e0..499b08f 100644 --- a/t/run/17join_count.tl +++ b/t/run/17join_count.tl @@ -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/run/18self_referencial.tl index b061adb..5759aca 100644 --- a/t/run/18self_referencial.tl +++ b/t/run/18self_referencial.tl @@ -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/run/19uuid.tl index 0da87f1..d4800d9 100644 --- a/t/run/19uuid.tl +++ b/t/run/19uuid.tl @@ -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 Data::UUID ; 1' or plan skip_all, 'Install Data::UUID run this test'; @@ -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/run/20unique.tl index 19481ef..9d7634c 100644 --- a/t/run/20unique.tl +++ b/t/run/20unique.tl @@ -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/run/21transactions.tl index eafc575..fe3c453 100644 --- a/t/run/21transactions.tl +++ b/t/run/21transactions.tl @@ -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 { @@ -169,6 +176,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/run/22cascade_copy.tl index 82642f2..e5048a1 100644 --- a/t/run/22cascade_copy.tl +++ b/t/run/22cascade_copy.tl @@ -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/run/23cache.tl index a822601..a3c94c0 100644 --- a/t/run/23cache.tl +++ b/t/run/23cache.tl @@ -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++ } ); @@ -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/run/24serialize.tl index 7c746f2..d79acba 100644 --- a/t/run/24serialize.tl +++ b/t/run/24serialize.tl @@ -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/run/25utf8.tl b/t/run/25utf8.tl index 278dde4..c0f39ed 100644 --- a/t/run/25utf8.tl +++ b/t/run/25utf8.tl @@ -1,23 +1,27 @@ -sub run_tests { - my $schema = shift; +use strict; +use warnings; - eval 'use Encode ; 1' - or plan skip_all, 'Install Encode run this test'; +use Test::More; +use lib qw(t/lib); +use DBICTest; - plan tests => 2; +my $schema = DBICTest::init_schema(); - DBICTest::Schema::Artist->load_components('UTF8Columns'); - DBICTest::Schema::Artist->utf8_columns('name'); - Class::C3->reinitialize(); +eval 'use Encode ; 1' + or plan skip_all => 'Install Encode run this test'; - my $artist = $schema->resultset("Artist")->create( { name => 'uni' } ); - ok( Encode::is_utf8( $artist->name ), 'got name with utf8 flag' ); +plan tests => 2; - 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' ); -} +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/26might_have.tl b/t/run/26might_have.tl index 0b700e8..1d4af78 100644 --- a/t/run/26might_have.tl +++ b/t/run/26might_have.tl @@ -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/run/27ordered.tl b/t/run/27ordered.tl index 3a53951..7a4847e 100644 --- a/t/run/27ordered.tl +++ b/t/run/27ordered.tl @@ -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 { @@ -101,4 +102,3 @@ sub check_rs { return 1; } -1; diff --git a/t/run/28result_set_column.tl b/t/run/28result_set_column.tl index e62cb62..e05dbb4 100644 --- a/t/run/28result_set_column.tl +++ b/t/run/28result_set_column.tl @@ -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 => 5; @@ -18,6 +24,3 @@ is($rs_title->min, 'Caterwaulin\' Blues', "min okay for title"); cmp_ok($rs_year->sum, '==', 9996, "three artists returned"); -} - -1; diff --git a/t/run/29dbicadmin.tl b/t/run/29dbicadmin.tl index 93c42a1..a411eb7 100644 --- a/t/run/29dbicadmin.tl +++ b/t/run/29dbicadmin.tl @@ -1,38 +1,41 @@ # vim: filetype=perl +use strict; +use warnings; -sub run_tests { +use Test::More; +use lib qw(t/lib); +use DBICTest; - eval 'require JSON'; - plan skip_all, 'Install JSON to run this test' if ($@); +my $schema = DBICTest::init_schema(); - 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 ($@); - } +eval 'require JSON'; +plan skip_all => 'Install JSON to run this test' if ($@); - plan tests => 5; - my $schema = shift; +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 ($@); +} - 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|; +plan tests => 5; - `$cmd --op=insert --set='{name:"Matt"}'`; - ok( ($employees->count()==1), 'insert count' ); +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|; - my $employee = $employees->find(1); - ok( ($employee->name() eq 'Matt'), 'insert valid' ); +`$cmd --op=insert --set='{name:"Matt"}'`; +ok( ($employees->count()==1), 'insert count' ); - `$cmd --op=update --set='{name:"Trout"}'`; - $employee = $employees->find(1); - ok( ($employee->name() eq 'Trout'), 'update' ); +my $employee = $employees->find(1); +ok( ($employee->name() eq 'Matt'), 'insert valid' ); - `$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=update --set='{name:"Trout"}'`; +$employee = $employees->find(1); +ok( ($employee->name() eq 'Trout'), 'update' ); - `$cmd --op=delete --where='{name:"Trout"}'`; - ok( ($employees->count()==1), 'delete' ); -} +`$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;