[Bast-commits] r3350 - branches/DBIx-Class/bulk_create/t

jnapiorkowski at dev.catalyst.perl.org jnapiorkowski at dev.catalyst.perl.org
Mon May 21 21:35:35 GMT 2007


Author: jnapiorkowski
Date: 2007-05-21 21:35:35 +0100 (Mon, 21 May 2007)
New Revision: 3350

Modified:
   branches/DBIx-Class/bulk_create/t/101populate_rs.t
Log:
clarify problem with missing relationship keys for bulk_insert mode

Modified: branches/DBIx-Class/bulk_create/t/101populate_rs.t
===================================================================
--- branches/DBIx-Class/bulk_create/t/101populate_rs.t	2007-05-21 20:31:20 UTC (rev 3349)
+++ branches/DBIx-Class/bulk_create/t/101populate_rs.t	2007-05-21 20:35:35 UTC (rev 3350)
@@ -10,7 +10,7 @@
 my $schema = DBICTest->init_schema();
 my $rs = $schema->resultset('Artist');
 
-RETURN_RESULTSETS: {
+RETURN_RESULTSETS_HAS_MANY: {
 
 	my ($crap, $girl, $damn, $xxxaaa) = $rs->populate( [
 	  { artistid => 4, name => 'Manufactured Crap', cds => [ 
@@ -47,7 +47,7 @@
 	ok( $girl->cds->count == 3, "got Expected Number of Cds");
 }
 
-RETURN_VOID: {
+RETURN_VOID_HAS_MANY: {
 
 	$rs->populate( [
 	  { artistid => 8, name => 'Manufactured CrapB', cds => [ 
@@ -148,15 +148,42 @@
 	ok( $girl->cds->count == 3, "got Expected Number of Cds");
 }
 
-## Test from a belongs_to perspective, should create artist first, then CD with artistid in:
-my $cd_rs = $schema->resultset('CD');
-$cd_rs->populate([ 
-                   { title => 'Some CD',
-                     year => 1997,
-                     artist => { name => 'Fred Bloggs'},
-                 }] );
-my $cd = $schema->resultset('CD')->find({title => 'Some CD'});
+RETURN_RESULTSETS_BELONGS_TO: {
 
-isa_ok($cd, 'DBICTest::CD', 'Created CD');
-isa_ok($cd->artist, 'DBICTest::Artist', 'Set Artist');
-is($cd->artist->name, 'Fred Bloggs', 'Set Artist to Fred');
+	## Test from a belongs_to perspective, should create artist first, then CD with artistid in:
+	
+	my $cds = [
+		{
+			title => 'Some CD1',
+			year => '1997',
+			artist => { name => 'Fred BloggsA'},
+		},
+		{
+			title => 'Some CD2',
+			year => '1997',
+			artist => { name => 'Fred BloggsB'},
+		},		
+	];
+	
+	my $cd_rs = $schema->resultset('CD');
+	
+	my @ret = $cd_rs->populate($cds);
+	
+	my $cdA = $schema->resultset('CD')->find({title => 'Some CD1'});
+
+	isa_ok($cdA, 'DBICTest::CD', 'Created CD');
+	isa_ok($cdA->artist, 'DBICTest::Artist', 'Set Artist');
+	is($cdA->artist->name, 'Fred BloggsA', 'Set Artist to FredA');
+
+	my $cdB = $schema->resultset('CD')->find({title => 'Some CD2'});
+	
+	isa_ok($cdB, 'DBICTest::CD', 'Created CD');
+	isa_ok($cdB->artist, 'DBICTest::Artist', 'Set Artist');
+	is($cdB->artist->name, 'Fred BloggsB', 'Set Artist to FredB');
+}
+
+
+
+
+
+




More information about the Bast-commits mailing list