More test hackage, some cleanup in ResultSet
[dbsrgits/DBIx-Class.git] / t / run / 06relationship.tl
index a954c1b..b0f8256 100644 (file)
@@ -6,14 +6,14 @@ use warnings;
 plan tests => 17;
 
 # has_a test
-my $cd = $schema->class("CD")->find(4);
+my $cd = $schema->resultset("CD")->find(4);
 my ($artist) = ($INC{'DBICTest/HelperRels'}
                   ? $cd->artist
                   : $cd->search_related('artist'));
 is($artist->name, 'Random Boy Band', 'has_a search_related ok');
 
 # has_many test with an order_by clause defined
-$artist = $schema->class("Artist")->find(1);
+$artist = $schema->resultset("Artist")->find(1);
 my @cds = ($INC{'DBICTest/HelperRels'}
              ? $artist->cds
              : $artist->search_related('cds'));
@@ -42,7 +42,7 @@ is( ($artist->search_related('cds'))[3]->title, 'Big Flop', 'create_related ok'
 is( $artist->count_related('cds'), 4, 'count_related ok' );
 
 # set_from_related
-my $track = $schema->class("Track")->create( {
+my $track = $schema->resultset("Track")->create( {
   trackid => 1,
   cd => 3,
   position => 98,
@@ -57,7 +57,7 @@ if ($INC{'DBICTest/HelperRels.pm'}) { # except inflated object
 }
 
 # update_from_related, the same as set_from_related, but it calls update afterwards
-$track = $schema->class("Track")->create( {
+$track = $schema->resultset("Track")->create( {
   trackid => 2,
   cd => 3,
   position => 99,
@@ -65,7 +65,7 @@ $track = $schema->class("Track")->create( {
 } );
 $track->update_from_related( cd => $cd );
 
-my $t_cd = ($schema->class("Track")->search( cd => 4, position => 99 ))[0]->cd;
+my $t_cd = ($schema->resultset("Track")->search( cd => 4, position => 99 ))[0]->cd;
 
 if ($INC{'DBICTest/HelperRels.pm'}) { # except inflated object
   is( $t_cd->cdid, 4, 'update_from_related ok' );
@@ -87,7 +87,7 @@ is( $cd->title, 'Greatest Hits', 'find_or_create_related new record ok' );
 is( ($artist->search_related('cds'))[4]->title, 'Greatest Hits', 'find_or_create_related new record search ok' );
 
 $artist->delete_related( cds => { title => 'Greatest Hits' });
-cmp_ok( $schema->class("CD")->search( title => 'Greatest Hits' ), '==', 0, 'delete_related ok' );
+cmp_ok( $schema->resultset("CD")->search( title => 'Greatest Hits' ), '==', 0, 'delete_related ok' );
 
 SKIP: {
   skip "relationship checking needs fixing", 1;
@@ -108,15 +108,15 @@ eval {
 like($@, qr/join condition/, 'failed when creating a rel without join condition, ok');
 
 # many_to_many helper test
-$cd = $schema->class("CD")->find(1);
+$cd = $schema->resultset("CD")->find(1);
 my @producers = $cd->producers();
 is( $producers[0]->name, 'Matt S Trout', 'many_to_many ok' );
 
 # test undirected many-to-many relationship (e.g. "related artists")
-my $undir_maps = $schema->class("Artist")->find(1)->artist_undirected_maps;
+my $undir_maps = $schema->resultset("Artist")->find(1)->artist_undirected_maps;
 is($undir_maps->count, 1, 'found 1 undirected map for artist 1');
 
-$undir_maps = $schema->class("Artist")->find(2)->artist_undirected_maps;
+$undir_maps = $schema->resultset("Artist")->find(2)->artist_undirected_maps;
 is($undir_maps->count, 1, 'found 1 undirected map for artist 2');
 
 my @art = $undir_maps->search_related('mapped_artists')->all;