From: David Kamholz Date: Thu, 6 Jul 2006 21:27:16 +0000 (+0000) Subject: more treelike tests X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=10ed6c253364191ca50df81689ee1351bac31ea8;p=dbsrgits%2FDBIx-Class-Historic.git more treelike tests --- diff --git a/t/76joins.t b/t/76joins.t index 2082047..d5b19ec 100644 --- a/t/76joins.t +++ b/t/76joins.t @@ -13,7 +13,7 @@ BEGIN { eval "use DBD::SQLite"; plan $@ ? ( skip_all => 'needs DBD::SQLite for testing' ) - : ( tests => 44 ); + : ( tests => 47 ); } # figure out if we've got a version of sqlite that is older than 3.2.6, in @@ -295,10 +295,22 @@ $schema->storage->debug(0); cmp_ok($queries, '==', 1, 'Only one query run'); -$tree_like = $schema->resultset('TreeLike')->find(1); +$schema->storage->debugcb(undef); +$schema->storage->debug(1); + +$tree_like = $schema->resultset('TreeLike')->search({'me.id' => 1}); $tree_like = $tree_like->search_related('children')->search_related('children')->search_related('children')->first; is($tree_like->name, 'quux', 'Tree search_related ok'); +$tree_like = $schema->resultset('TreeLike')->search({ 'me.id' => 2 }); +$tree_like = $tree_like->search_related('children', undef, { prefetch => { children => 'children' } })->first; +is($tree_like->children->first->name, 'quux', 'Tree search_related with prefetch ok'); + +$tree_like = $schema->resultset('TreeLike')->search( + { 'children.id' => 2, 'children_2.id' => 5 }, + { join => [qw/children children/] })->first; +is($tree_like->name, 'foo', 'Tree with multiple has_many joins ok'); + # test that collapsed joins don't get a _2 appended to the alias my $sql = ''; diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index c90cf3e..e64f796 100755 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -194,6 +194,7 @@ sub populate_schema { [ qw/id parent name/ ], [ 1, 0, 'foo' ], [ 2, 1, 'bar' ], + [ 5, 1, 'blop' ], [ 3, 2, 'baz' ], [ 4, 3, 'quux' ], ]);