From: Simon Elliott Date: Mon, 3 Apr 2006 17:25:18 +0000 (+0000) Subject: New tests for cascade_delete, including fail. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a4731ae021a6423b907a945b6728335946a0a67a;p=dbsrgits%2FDBIx-Class-Historic.git New tests for cascade_delete, including fail. --- diff --git a/t/run/01core.tl b/t/run/01core.tl index c41ef17..0bc257a 100644 --- a/t/run/01core.tl +++ b/t/run/01core.tl @@ -1,7 +1,7 @@ sub run_tests { my $schema = shift; -plan tests => 41; +plan tests => 43; my @art = $schema->resultset("Artist")->search({ }, { order_by => 'name DESC'}); @@ -144,7 +144,8 @@ my $rel_rs = $tag_rs->search_related('cd'); cmp_ok($rel_rs->count, '==', 5, 'Related search ok'); cmp_ok($or_rs->next->cdid, '==', $rel_rs->next->cdid, 'Related object ok'); - +$or_rs->reset; +$rel_rs->reset; my $tag = $schema->resultset('Tag')->search( [ { 'me.tag' => 'Blue' } ], { cols=>[qw/tagid/] } )->next; @@ -154,6 +155,12 @@ cmp_ok($tag->has_column_loaded('tag'), '==', 0, 'Has not tag loaded'); ok($schema->storage(), 'Storage available'); +#test cascade_delete thru many_many relations +my $art_del = $schema->resultset("Artist")->find({ artistid => 1 }); +$art_del->delete; +cmp_ok( $schema->resultset("CD")->search({artist => 1}), '==', 0, 'Cascading through has_many top level.'); +cmp_ok( $schema->resultset("CD_to_Producer")->search({cd => 1}), '==', 0, 'Cascading through has_many children.'); + $schema->source("Artist")->{_columns}{'artistid'} = {}; my $typeinfo = $schema->source("Artist")->column_info('artistid');