sub _register_source {
my ($self, $moniker, $source, $params) = @_;
+ my $orig_source = $source;
+
$source = $source->new({ %$source, source_name => $moniker });
+ $source->schema($self);
+ weaken($source->{schema}) if ref($self);
+
+ my $rs_class = $source->result_class;
+
my %reg = %{$self->source_registrations};
$reg{$moniker} = $source;
$self->source_registrations(\%reg);
- $source->schema($self);
- weaken($source->{schema}) if ref($self);
return if ($params->{extra});
- if ($source->result_class) {
- my %map = %{$self->class_mappings};
- if (exists $map{$source->result_class}
- && $map{$source->result_class} ne $moniker) {
- warn $source->result_class . ' already has a source, use register_extra_source for additional sources';
- }
- $map{$source->result_class} = $moniker;
- $self->class_mappings(\%map);
+ my %map = %{$self->class_mappings};
+ if (exists $map{$rs_class} and $rs_class->result_source_instance ne $orig_source) {
+ carp "$rs_class already has a source, use register_extra_source for additional sources";
}
+ $map{$rs_class} = $moniker;
+ $self->class_mappings(\%map);
}
sub _unregister_source {
use strict;
use warnings;
-use Test::More skip_all => 'Postponed until after 0.08100';
use lib 't/lib';
-
-=begin
-
-How did this get back here? The test is borked, there is a branch with
-the correct test and a tentative fix - branches/subclassed_rsset
-
-Make sure to nuke this file when merging, it is only left here to make
-merging of the above branch easier.
-
-
-ribasushi
-
-
-=cut
-
-
-__END__
-
-
-
-plan tests => 15;
+use Test::More tests => 8;
sub _chk_warning {
defined $_[0]?
\@monikers,
'List of resultsource registrations',
);
-
- my %seen_rc;
- for my $m (@monikers) {
- my $src = DBICNSTest::RtBug41083->source ($m);
- my $rc = $src->result_class;
-
- ok ( (++$seen_rc{$rc} == 1), "result_class of $m is unique")
- || diag "Source: $m, result_class: $rc";
- like ($rc, qr/:: $m $/x, 'result_class matches moniker');
- }
}
{
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More tests => 2;
use lib qw(t/lib);
use DBICTest;
use DBICTest::Schema;
use DBICTest::Schema::Artist;
DBICTest::Schema::Artist->source_name('MyArtist');
-{
- my $w;
- local $SIG{__WARN__} = sub { $w = shift };
- DBICTest::Schema->register_class('FooA', 'DBICTest::Schema::Artist');
- like ($w, qr/use register_extra_source/, 'Complain about using register_class on an already-registered class');
-}
+DBICTest::Schema->register_class('FooA', 'DBICTest::Schema::Artist');
my $schema = DBICTest->init_schema();