TODOified test for RT#40701
[dbsrgits/DBIx-Class.git] / t / delete / related.t
index 39aa429..49cd88f 100644 (file)
@@ -4,12 +4,13 @@ use warnings;
 use lib qw(t/lib);
 use DBICTest;
 
-plan tests => 6;
+plan tests => 4;
 
 my $schema = DBICTest->init_schema();
 
 my $ars = $schema->resultset('Artist');
 my $cdrs = $schema->resultset('CD');
+my $cd2pr_rs = $schema->resultset('CD_to_Producer');
 
 # create some custom entries
 $ars->populate ([
@@ -18,6 +19,7 @@ $ars->populate ([
   [qw/72        a2/],
   [qw/73        a3/],
 ]);
+
 $cdrs->populate ([
   [qw/cdid artist title   year/],
   [qw/70   71     delete0 2005/],
@@ -28,6 +30,13 @@ $cdrs->populate ([
   [qw/75   73     delete5 2008/],
 ]);
 
+my $prod = $schema->resultset('Producer')->create ({ name => 'deleter' });
+my $prod_cd = $cdrs->find (70);
+my $cd2pr = $cd2pr_rs->create ({
+  producer => $prod,
+  cd => $prod_cd,
+});
+
 my $total_cds = $cdrs->count;
 
 # test that delete_related w/o conditions deletes all related records only
@@ -44,45 +53,9 @@ is ($cdrs->count, $total_cds -= 2, 'related + condition delete ok');
 $a2_cds->search ({}, { rows => 1})->delete;
 is ($cdrs->count, $total_cds -= 1, 'related + limit delete ok');
 
-my $tkfk = $schema->resultset('FourKeys_to_TwoKeys');
-
-my ($fa, $fb) = $tkfk->related_resultset ('fourkeys')->populate ([
-  [qw/foo bar hello goodbye sensors/],
-  [qw/1   1   1     1       a      /],
-  [qw/2   2   2     2       b      /],
-]);
-
-# This is already provided by DBICTest
-#my ($ta, $tb) = $tkfk->related_resultset ('twokeys')->populate ([
-#  [qw/artist  cd /],
-#  [qw/1       1  /],
-#  [qw/2       2  /],
-#]);
-my ($ta, $tb) = $schema->resultset ('TwoKeys')
-                  ->search ( [ { artist => 1, cd => 1 }, { artist => 2, cd => 2 } ])
-                    ->all;
-
-my $tkfk_cnt = $tkfk->count;
-
-my $non_void_ctx = $tkfk->populate ([
-  { autopilot => 'a', fourkeys =>  $fa, twokeys => $ta },
-  { autopilot => 'b', fourkeys =>  $fb, twokeys => $tb },
-  { autopilot => 'x', fourkeys =>  $fa, twokeys => $tb },
-  { autopilot => 'y', fourkeys =>  $fb, twokeys => $ta },
-]);
-is ($tkfk->count, $tkfk_cnt += 4, 'FourKeys_to_TwoKeys populated succesfully');
-
-my $sub_rs = $tkfk->search (
-  [ 
-    { map { $_ => 1 } qw/artist.artistid cd.cdid fourkeys.foo fourkeys.bar fourkeys.hello fourkeys.goodbye/ },
-    { map { $_ => 2 } qw/artist.artistid cd.cdid fourkeys.foo fourkeys.bar fourkeys.hello fourkeys.goodbye/ },
-  ],
-  {
-    join => [ 'fourkeys', { twokeys => [qw/artist cd/] } ],
-  },
-);
-
-is ($sub_rs->count, 2, 'Only two rows from fourkeys match');
-$sub_rs->delete;
-
-is ($tkfk->count, $tkfk_cnt -= 2, 'Only two rows deleted');
+TODO: {
+  local $TODO = 'delete_related is based on search_related which is based on search which does not understand object arguments';
+  my $cd2pr_count = $cd2pr_rs->count;
+  $prod_cd->delete_related('cd_to_producer', { producer => $prod } );
+  is ($cd2pr_rs->count, $cd2pr_count -= 1, 'm2m link deleted succesfully');
+}