# has_a test
my $cd = $schema->resultset("CD")->find(4);
-my ($artist) = ($INC{'DBICTest/HelperRels'}
- ? $cd->artist
- : $cd->search_related('artist'));
+my ($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->resultset("Artist")->find(1);
-my @cds = ($INC{'DBICTest/HelperRels'}
- ? $artist->cds
- : $artist->search_related('cds'));
+my @cds = $artist->search_related('cds');
is( $cds[1]->title, 'Spoonful of bees', 'has_many search_related with order_by ok' );
# search_related with additional abstract query
-@cds = ($INC{'DBICTest/HelperRels'}
- ? $artist->cds({ title => { like => '%of%' } })
- : $artist->search_related('cds', { title => { like => '%of%' } } )
- );
+@cds = $artist->search_related('cds', { title => { like => '%of%' } } );
is( $cds[1]->title, 'Forkful of bees', 'search_related with abstract query ok' );
# creating a related object
-if ($INC{'DBICTest/HelperRels.pm'}) {
- $artist->add_to_cds({ title => 'Big Flop', year => 2005 });
-} else {
- my $big_flop = $artist->create_related( 'cds', {
- title => 'Big Flop',
- year => 2005,
- } );
-
- TODO: {
- local $TODO = "Can't fix right now" if $DBIx::Class::VERSION < 0.09;
- lives_ok { $big_flop->genre} "Don't throw exception when col is not loaded after insert";
- };
-}
+$artist->create_related( 'cds', {
+ title => 'Big Flop',
+ year => 2005,
+} );
my $big_flop_cd = ($artist->search_related('cds'))[3];
is( $big_flop_cd->title, 'Big Flop', 'create_related ok' );
'No back rel'
);
+throws_ok {
+ my $new_bookmark = $schema->resultset("Bookmark")->new_result( {} );
+ $new_bookmark->new_related( no_such_rel => {} );
+} qr/No such relationship 'no_such_rel'/, 'creating in uknown rel throws';
-TODO: {
+{
local $TODO = "relationship checking needs fixing";
# try to add a bogus relationship using the wrong cols
throws_ok {
# many_to_many helper tests
$cd = $schema->resultset("CD")->find(1);
-my @producers = $cd->producers();
+my @producers = $cd->producers(undef, { order_by => 'producerid'} );
is( $producers[0]->name, 'Matt S Trout', 'many_to_many ok' );
is( $cd->producers_sorted->next->name, 'Bob The Builder',
'sorted many_to_many ok' );