9 package DBICTest::ResultSource::OtherSource;
12 use base qw/DBIx::Class::ResultSource::Table/;
17 my $schema = DBICTest->init_schema();
18 my $artist_source = $schema->source('Artist');
20 my $new_source = DBICTest::ResultSource::OtherSource->new({
22 name => 'artist_preview',
23 _relationships => Storable::dclone( $artist_source->_relationships ),
26 $new_source->add_column('other_col' => { data_type => 'integer', default_value => 1 });
29 local $SIG{__WARN__} = sub { $warn = shift };
32 $schema->register_extra_source( 'artist->extra' => $new_source );
34 my $source = $schema->source('DBICTest::Artist');
35 is($source->source_name, 'Artist', 'original source still primary source');
39 my $source = $schema->source('DBICTest::Artist');
40 $schema->register_source($source->source_name, $source);
41 is($warn, '', "re-registering an existing source under the same name causes no errors");
45 my $new_source_name = 'Artist->preview(artist_preview)';
46 $schema->register_source( $new_source_name => $new_source );
48 ok(($warn =~ /DBICTest::Artist already has a source, use register_extra_source for additional sources/), 'registering extra source causes errors');
50 my $source = $schema->source('DBICTest::Artist');
51 is($source->source_name, $new_source_name, 'original source still primary source');