[Bast-commits] r5155 - DBIx-Class/0.08/trunk/t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Mon Nov 17 02:09:19 GMT 2008


Author: ribasushi
Date: 2008-11-17 02:09:18 +0000 (Mon, 17 Nov 2008)
New Revision: 5155

Modified:
   DBIx-Class/0.08/trunk/t/96multi_create.t
Log:
Two failing multicreate tests (the root cause of castaway's problem)

Modified: DBIx-Class/0.08/trunk/t/96multi_create.t
===================================================================
--- DBIx-Class/0.08/trunk/t/96multi_create.t	2008-11-17 01:59:53 UTC (rev 5154)
+++ DBIx-Class/0.08/trunk/t/96multi_create.t	2008-11-17 02:09:18 UTC (rev 5155)
@@ -6,7 +6,7 @@
 use lib qw(t/lib);
 use DBICTest;
 
-plan tests => 72;
+plan tests => 86;
 
 my $schema = DBICTest->init_schema();
 
@@ -168,6 +168,93 @@
 };
 diag $@ if $@;
 
+# test might_have again but with a PK == FK in the middle (obviously not specified)
+eval {
+  my $artist = $schema->resultset('Artist')->first;
+  my $cd = $schema->resultset('CD')->create ({
+    artist => $artist,
+    title => 'Music to code by at twilight',
+    year => 2008,
+    artwork => {
+      images => [
+        { name => 'recursive descent' },
+        { name => 'tail packing' },
+      ],
+    },
+  });
+
+  isa_ok ($cd, 'DBICTest::CD', 'Main CD object created');
+  is ($cd->title, 'Music to code by at twilight', 'Correct CD title');
+  isa_ok ($cd->artwork, 'DBICTest::Artwork', 'Artwork created');
+
+  # this test might look weird, but it failed at one point, keep it there
+  is ($cd->artwork->images->count, 2, 'Correct artwork image count via the new object');
+  is_deeply (
+    [ sort $cd->artwork->images->get_column ('name')->all ],
+    [ 'recursive descent', 'tail packing' ],
+    'Images named correctly in objects',
+  );
+
+
+  my $artwork = $schema->resultset('Artwork')->search (
+    { 'cd.title' => 'Music to code by at twilight' },
+    { join => 'cd' },
+  )->single;
+
+  is ($artwork->images->count, 2, 'Correct artwork image count via a new search');
+
+  is_deeply (
+    [ sort $artwork->images->get_column ('name')->all ],
+    [ 'recursive descent', 'tail packing' ],
+    'Images named correctly after search',
+  );
+};
+diag $@ if $@;
+
+# test might_have again but with just a PK and FK (neither specified) in the mid-table
+eval {
+  my $cd = $schema->resultset('CD')->first;
+  my $track = $schema->resultset ('Track')->create ({
+    cd => $cd,
+    position => 66,
+    title => 'Black',
+    lyrics => {
+      lyric_versions => [
+        { text => 'The color black' },
+        { text => 'The colour black' },
+      ],
+    },
+  });
+
+  isa_ok ($track, 'DBICTest::Track', 'Main track object created');
+  is ($track->title, 'Black', 'Correct track title');
+  isa_ok ($track->lyrics, 'DBICTest::Lyrics', 'Lyrics created');
+
+  # this test might look weird, but it was failing at one point, keep it there
+  is ($track->lyrics->lyric_versions->count, 2, 'Correct lyric versions count via the new object');
+
+  is_deeply (
+    [ sort $track->lyrics->lyric_versions->get_column ('text')->all ],
+    [ 'The color black', 'The colour black' ],
+    'Lyrics text in objects matches',
+  );
+
+
+  my $lyric = $schema->resultset('Lyrics')->search (
+    { 'track.title' => 'Black' },
+    { join => 'track' },
+  )->single;
+
+  is ($lyric->lyric_versions->count, 2, 'Correct lyric versions count via a new search');
+
+  is_deeply (
+    [ sort $lyric->lyric_versions->get_column ('text')->all ],
+    [ 'The color black', 'The colour black' ],
+    'Lyrics text via search matches',
+  );
+};
+diag $@ if $@;
+
 # nested find_or_create
 eval {
   my $newartist2 = $schema->resultset('Artist')->find_or_create({ 




More information about the Bast-commits mailing list