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

jnapiorkowski at dev.catalyst.perl.org jnapiorkowski at dev.catalyst.perl.org
Tue May 8 21:43:09 GMT 2007


Author: jnapiorkowski
Date: 2007-05-08 21:43:07 +0100 (Tue, 08 May 2007)
New Revision: 3268

Modified:
   branches/DBIx-Class/bulk_create/t/96multi_create.t
Log:
Added a test for create related and a second test to highlite a maybe issue

Modified: branches/DBIx-Class/bulk_create/t/96multi_create.t
===================================================================
--- branches/DBIx-Class/bulk_create/t/96multi_create.t	2007-05-08 20:08:06 UTC (rev 3267)
+++ branches/DBIx-Class/bulk_create/t/96multi_create.t	2007-05-08 20:43:07 UTC (rev 3268)
@@ -7,7 +7,7 @@
 
 my $schema = DBICTest->init_schema();
 
-plan tests => 6;
+plan tests => 11;
 
 my $cd2 = $schema->resultset('CD')->create({ artist => 
                                    { name => 'Fred Bloggs' },
@@ -41,6 +41,7 @@
 
 is($newartist->name, 'Fred 2', 'Retrieved the artist');
 
+
 my $newartist2 = $schema->resultset('Artist')->find_or_create({ name => 'Fred 3',
                                                                 cds => [
                                                                         { title => 'Noah Act',
@@ -51,3 +52,69 @@
                                                               });
 
 is($newartist2->name, 'Fred 3', 'Created new artist with cds via find_or_create');
+
+
+CREATE_RELATED1 :{
+
+	my $artist = $schema->resultset('Artist')->first;
+	
+	my $cd_result = $artist->create_related('cds', {
+	
+		title => 'TestOneCD1',
+		year => 2007,
+		tracks => [
+		
+			{ position=>111,
+			  title => 'TrackOne',
+			},
+			{ position=>112,
+			  title => 'TrackTwo',
+			}
+		],
+
+	});
+	
+	ok( $cd_result && ref $cd_result eq 'DBICTest::CD', "Got Good CD Class");
+	ok( $cd_result->title eq "TestOneCD1", "Got Expected Title");
+	
+	my $tracks = $cd_result->tracks;
+	
+	ok( ref $tracks eq "DBIx::Class::ResultSet", "Got Expected Tracks ResultSet");
+	
+	foreach my $track ($tracks->all)
+	{
+		ok( $track && ref $track eq 'DBICTest::Track', 'Got Expected Track Class');
+	}
+}
+
+CREATE_RELATED2 :{
+
+	
+	my $cd_result = $schema->resultset('Artist')->first->create_related('cds', {
+	
+		title => 'TestOneCD1',
+		year => 2007,
+		tracks => [
+		
+			{ position=>111,
+			  title => 'TrackOne',
+			},
+			{ position=>112,
+			  title => 'TrackTwo',
+			}
+		],
+
+	});
+	
+	ok( $cd_result && ref $cd_result eq 'DBICTest::CD', "Got Good CD Class");
+	ok( $cd_result->title eq "TestOneCD1", "Got Expected Title");
+	
+	my $tracks = $cd_result->tracks;
+	
+	ok( ref $tracks eq "DBIx::Class::ResultSet", "Got Expected Tracks ResultSet");
+	
+	foreach my $track ($tracks->all)
+	{
+		ok( $track && ref $track eq 'DBICTest::Track', 'Got Expected Track Class');
+	}
+}




More information about the Bast-commits mailing list