[Bast-commits] r5073 - in DBIx-Class/0.08/trunk/t: . lib/DBICTest/Schema

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Fri Nov 7 09:42:48 GMT 2008


Author: ribasushi
Date: 2008-11-07 09:42:48 +0000 (Fri, 07 Nov 2008)
New Revision: 5073

Modified:
   DBIx-Class/0.08/trunk/t/96multi_create.t
   DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Bookmark.pm
Log:
One extra multicreate test and some cleanup

Modified: DBIx-Class/0.08/trunk/t/96multi_create.t
===================================================================
--- DBIx-Class/0.08/trunk/t/96multi_create.t	2008-11-07 07:30:49 UTC (rev 5072)
+++ DBIx-Class/0.08/trunk/t/96multi_create.t	2008-11-07 09:42:48 UTC (rev 5073)
@@ -5,13 +5,13 @@
 use lib qw(t/lib);
 use DBICTest;
 
-plan tests => 55;
+plan tests => 58;
 
 my $schema = DBICTest->init_schema();
 
-# simple create + belongs_to
+# simple create + parent (the stuff $rs belongs_to)
 eval {
-  my $cd2 = $schema->resultset('CD')->create({
+  my $cd = $schema->resultset('CD')->create({
     artist => { 
       name => 'Fred Bloggs' 
     },
@@ -19,12 +19,35 @@
     year => 1996
   });
 
-  isa_ok($cd2, 'DBICTest::CD', 'Created CD object');
-  isa_ok($cd2->artist, 'DBICTest::Artist', 'Created related Artist');
-  is($cd2->artist->name, 'Fred Bloggs', 'Artist created correctly');
+  isa_ok($cd, 'DBICTest::CD', 'Created CD object');
+  isa_ok($cd->artist, 'DBICTest::Artist', 'Created related Artist');
+  is($cd->artist->name, 'Fred Bloggs', 'Artist created correctly');
 };
 diag $@ if $@;
 
+# same as above but the child and parent have no values, 
+# except for an explicit parent pk
+eval {
+  my $bm_rs = $schema->resultset('Bookmark');
+  my $bookmark = $bm_rs->create({
+    link => {
+      id => 66,
+    },
+  });
+
+  isa_ok($bookmark, 'DBICTest::Bookmark', 'Created Bookrmark object');
+  isa_ok($bookmark->link, 'DBICTest::Link', 'Created related Link');
+  is (
+    $bm_rs->search (
+      { 'link.title' => $bookmark->link->title },
+      { join => 'link' },
+    )->count,
+    1,
+    'Bookmark and link made it to the DB',
+  );
+};
+diag $@ if $@;
+
 # create over > 1 levels of has_many create (A => { has_many => { B => has_many => C } } )
 eval {
   my $artist = $schema->resultset('Artist')->create(
@@ -417,7 +440,7 @@
       { join => 'tags', group_by => 'me.cdid' }
     ),
     5,
-    '10 tags were pairwise distributed between 5 CDs'
+    'All 10 tags were pairwise distributed between 5 year-2012 CDs'
   );
 
   my $paul_prod = $cd_rs->search (
@@ -483,7 +506,7 @@
   is (
     $bob_prod->search ({ 'artist.name' => 'james' }, { join => 'artist' })->count,
     1,
-    "Bob prpdoced james' only CD",
+    "Bob produced james' only CD",
   );
 };
 diag $@ if $@;

Modified: DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Bookmark.pm
===================================================================
--- DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Bookmark.pm	2008-11-07 07:30:49 UTC (rev 5072)
+++ DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Bookmark.pm	2008-11-07 09:42:48 UTC (rev 5073)
@@ -8,7 +8,6 @@
 use warnings;
 
 __PACKAGE__->table('bookmark');
-__PACKAGE__->add_columns(qw/id link/);
 __PACKAGE__->add_columns(
     'id' => {
         data_type => 'integer',




More information about the Bast-commits mailing list