From: Michael G Schwern Date: Thu, 14 Feb 2008 09:57:52 +0000 (-0800) Subject: cascade delete test from Class-DBI 3.0.17 X-Git-Tag: v0.08240~541^2~18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=37702ea526edc26a864703c78f076278adf76e45;p=dbsrgits%2FDBIx-Class.git cascade delete test from Class-DBI 3.0.17 --- diff --git a/t/cdbi-t/23-cascade.t b/t/cdbi-t/23-cascade.t new file mode 100644 index 0000000..7e17419 --- /dev/null +++ b/t/cdbi-t/23-cascade.t @@ -0,0 +1,28 @@ +use strict; +use Test::More; + +BEGIN { + eval "use DBD::SQLite"; + plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 5); +} + +use lib 't/testlib'; +use Film; +use Director; + +{ # Cascade Strategies + Director->has_many(nasties => Film => { cascade => 'Fail' }); + + my $dir = Director->insert({ name => "Nasty Noddy" }); + my $kk = $dir->add_to_nasties({ Title => 'Killer Killers' }); + is $kk->director, $dir, "Director set OK"; + is $dir->nasties, 1, "We have one nasty"; + eval { $dir->delete }; + like $@, qr/1/, "Can't delete while films exist"; + my $rr = $dir->add_to_nasties({ Title => 'Revenge of the Revengers' }); + eval { $dir->delete }; + like $@, qr/2/, "Still can't delete"; + $dir->nasties->delete_all; + eval { $dir->delete }; + is $@, '', "Can delete once films are gone"; +}