6 eval "use DBIx::Class::CDBICompat;";
8 plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required');
14 use lib 't/cdbi/testlib';
20 Director->has_many(nasties => 'Film');
22 my $dir = Director->insert({
23 name => "Lewis Teague",
25 my $kk = $dir->add_to_nasties({
28 is $kk->director, $dir, "Director set OK";
29 is $dir->nasties, 1, "We have one nasty";
32 ok !Film->retrieve("Alligator"), "has_many cascade deletes by default";
36 # Two ways of saying not to cascade
37 for my $args ({ no_cascade_delete => 1 }, { cascade => "None" }) {
38 Director->has_many(nasties => 'Film', $args);
40 my $dir = Director->insert({
41 name => "Lewis Teague",
43 my $kk = $dir->add_to_nasties({
46 is $kk->director, $dir, "Director set OK";
47 is $dir->nasties, 1, "We have one nasty";
50 local $Data::Dumper::Terse = 1;
51 ok +Film->retrieve("Alligator"), 'has_many with ' . Dumper ($args);;
57 # local $TODO = 'cascade => "Fail" unimplemented';
59 # Director->has_many(nasties => Film => { cascade => 'Fail' });
61 # my $dir = Director->insert({ name => "Nasty Noddy" });
62 # my $kk = $dir->add_to_nasties({ Title => 'Killer Killers' });
63 # is $kk->director, $dir, "Director set OK";
64 # is $dir->nasties, 1, "We have one nasty";
66 # ok !eval { $dir->delete };
67 # like $@, qr/1/, "Can't delete while films exist";
69 # my $rr = $dir->add_to_nasties({ Title => 'Revenge of the Revengers' });
70 # ok !eval { $dir->delete };
71 # like $@, qr/2/, "Still can't delete";
73 # $dir->nasties->delete_all;
74 # ok eval { $dir->delete };
75 # is $@, '', "Can delete once films are gone";