Fix package names in documentation
[dbsrgits/DBIx-Class-Historic.git] / t / 96multi_create.t
index ac5f219..810b6eb 100644 (file)
@@ -1,15 +1,12 @@
 use strict;
 use warnings;
 
-use Test::More;
+use Test::More qw(no_plan);
 use lib qw(t/lib);
 use DBICTest;
-use DateTime;
 
 my $schema = DBICTest->init_schema();
 
-plan tests => 17;
-
 my $cd2 = $schema->resultset('CD')->create({ artist => 
                                    { name => 'Fred Bloggs' },
                                    title => 'Some CD',
@@ -106,10 +103,13 @@ CREATE_RELATED2 :{
                        }
                ],
 
+    liner_notes => { notes => 'I can haz liner notes?' },
+
        });
        
        ok( $cd_result && ref $cd_result eq 'DBICTest::CD', "Got Good CD Class");
        ok( $cd_result->title eq "TestOneCD2", "Got Expected Title");
+  ok( $cd_result->notes eq 'I can haz liner notes?', 'Liner notes');
        
        my $tracks = $cd_result->tracks;
        
@@ -120,3 +120,44 @@ CREATE_RELATED2 :{
                ok( $track && ref $track eq 'DBICTest::Track', 'Got Expected Track Class');
        }
 }
+
+my $cdp = $schema->resultset('CD_to_Producer')->create({
+            cd => { artist => 1, title => 'foo', year => 2000 },
+            producer => { name => 'jorge' }
+          });
+
+ok($cdp, 'join table record created ok');
+
+SPECIAL_CASE: {
+  my $kurt_cobain = { name => 'Kurt Cobain' };
+
+  my $in_utero = $schema->resultset('CD')->new({
+      title => 'In Utero',
+      year  => 1993
+    });
+
+  $kurt_cobain->{cds} = [ $in_utero ];
+
+
+  $schema->resultset('Artist')->populate([ $kurt_cobain ]); # %)
+  $a = $schema->resultset('Artist')->find({name => 'Kurt Cobain'});
+
+  is($a->name, 'Kurt Cobain', 'Artist insertion ok');
+  is($a->cds && $a->cds->first && $a->cds->first->title, 
+                 'In Utero', 'CD insertion ok');
+}
+
+SPECIAL_CASE2: {
+  my $pink_floyd = { name => 'Pink Floyd' };
+
+  my $the_wall = { title => 'The Wall', year  => 1979 };
+
+  $pink_floyd->{cds} = [ $the_wall ];
+
+
+  $schema->resultset('Artist')->populate([ $pink_floyd ]); # %)
+  $a = $schema->resultset('Artist')->find({name => 'Pink Floyd'});
+
+  is($a->name, 'Pink Floyd', 'Artist insertion ok');
+  is($a->cds && $a->cds->first->title, 'The Wall', 'CD insertion ok');
+}