Remove bogus test:
[dbsrgits/DBIx-Class.git] / t / 96multi_create_new.t
CommitLineData
d4d6aae3 1use strict;
2use warnings;
3
4use Test::More;
5use Test::Exception;
6use lib qw(t/lib);
7use DBICTest;
8
9plan 'no_plan';
10
11my $schema = DBICTest->init_schema();
12
13# Test various new() invocations - this is all about backcompat, making
14# sure that insert() still works as expected by legacy code.
15#
16# What we essentially do is multi-instantiate objects, making sure nothing
17# gets inserted. Then we add some more objects to the mix either via
18# new_related() or by setting an accessor directly (or both) - again
19# expecting no inserts. Then after calling insert() on the starter object
a6a1ec32 20# we expect everything supplied to new() to get inserted, as well as any
21# relations whose PK's are necessary to complete the objects supplied
22# to new(). All other objects should be insert()able afterwards too.
d4d6aae3 23
24
25my $new_artist = $schema->resultset("Artist")->new_result({ 'name' => 'Depeche Mode' });
26my $new_related_cd = $new_artist->new_related('cds', { 'title' => 'Leave in Silence', 'year' => 1982});
27eval {
28 $new_artist->insert;
29 $new_related_cd->insert;
30};
31is ($@, '', 'Staged insertion successful');
32ok($new_artist->in_storage, 'artist inserted');
33ok($new_related_cd->in_storage, 'new_related_cd inserted');
34
35
36my $new_cd = $schema->resultset("CD")->new_result({});
37my $new_related_artist = $new_cd->new_related('artist', { 'name' => 'Marillion',});
38lives_ok (
39 sub {
40 $new_related_artist->insert;
41 $new_cd->title( 'Misplaced Childhood' );
42 $new_cd->year ( 1985 );
43 $new_cd->artist( $new_related_artist ); # For exact backward compatibility
44 $new_cd->insert;
45 },
46 'Reversed staged insertion successful'
47);
48ok($new_related_artist->in_storage, 'related artist inserted');
49ok($new_cd->in_storage, 'cd inserted');