9 my $schema = DBICTest->init_schema();
13 my $cd2 = $schema->resultset('CD')->create({ artist =>
14 { name => 'Fred Bloggs' },
19 is(ref $cd2->artist, 'DBICTest::Artist', 'Created CD and Artist object');
20 is($cd2->artist->name, 'Fred Bloggs', 'Artist created correctly');
22 my $artist = $schema->resultset('Artist')->create({ name => 'Fred 2',
24 { title => 'Music to code by',
29 is(ref $artist->cds->first, 'DBICTest::CD', 'Created Artist with CDs');
30 is($artist->cds->first->title, 'Music to code by', 'CD created correctly');
33 $artist->update({cds => [ $artist->cds,
34 { title => 'Yet another CD',
39 is(($artist->cds->search({}, { order_by => 'year' }))[0]->title, 'Yet another CD', 'Updated and added another CD');
41 my $newartist = $schema->resultset('Artist')->find_or_create({ name => 'Fred 2'});
43 is($newartist->name, 'Fred 2', 'Retrieved the artist');
46 my $newartist2 = $schema->resultset('Artist')->find_or_create({ name => 'Fred 3',
48 { title => 'Noah Act',
55 is($newartist2->name, 'Fred 3', 'Created new artist with cds via find_or_create');
60 my $artist = $schema->resultset('Artist')->first;
62 my $cd_result = $artist->create_related('cds', {
64 title => 'TestOneCD1',
78 ok( $cd_result && ref $cd_result eq 'DBICTest::CD', "Got Good CD Class");
79 ok( $cd_result->title eq "TestOneCD1", "Got Expected Title");
81 my $tracks = $cd_result->tracks;
83 ok( ref $tracks eq "DBIx::Class::ResultSet", "Got Expected Tracks ResultSet");
85 foreach my $track ($tracks->all)
87 ok( $track && ref $track eq 'DBICTest::Track', 'Got Expected Track Class');
93 my $artist = $schema->resultset('Artist')->first;
95 my $cd_result = $artist->create_related('cds', {
97 title => 'TestOneCD2',
111 ok( $cd_result && ref $cd_result eq 'DBICTest::CD', "Got Good CD Class");
112 ok( $cd_result->title eq "TestOneCD2", "Got Expected Title");
114 my $tracks = $cd_result->tracks;
116 ok( ref $tracks eq "DBIx::Class::ResultSet", "Got Expected Tracks ResultSet");
118 foreach my $track ($tracks->all)
120 ok( $track && ref $track eq 'DBICTest::Track', 'Got Expected Track Class');