X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F39load_namespaces_rt41083.t;h=5a6ea8282e9210ddaa843339dc5e4976fd19cf8d;hb=6882de2b334aac0a278b1984e82ddaca2ddff2b4;hp=ba99fe56684df3db7f618fdce369edb513be0c92;hpb=1a304e513dc3fb708512877ab25423b567e1bedc;p=dbsrgits%2FDBIx-Class.git diff --git a/t/39load_namespaces_rt41083.t b/t/39load_namespaces_rt41083.t index ba99fe5..5a6ea82 100644 --- a/t/39load_namespaces_rt41083.t +++ b/t/39load_namespaces_rt41083.t @@ -2,41 +2,77 @@ use strict; use warnings; -use Test::More; +use Test::More skip_all => 'Postponed until after 0.08100'; use lib 't/lib'; -plan tests => 4; +plan tests => 15; sub _chk_warning { - defined $_[0]? - $_[0] !~ qr/We found ResultSet class '([^']+)' for '([^']+)', but it seems that you had already set '([^']+)' to use '([^']+)' instead/ : - 1 + defined $_[0]? + $_[0] !~ qr/We found ResultSet class '([^']+)' for '([^']+)', but it seems that you had already set '([^']+)' to use '([^']+)' instead/ : + 1 } -my $warnings; -eval { +sub _chk_extra_sources_warning { + my $p = qr/already has a source, use register_extra_source for additional sources/; + defined $_[0]? $_[0] !~ /$p/ : 1; +} + +sub _verify_sources { + my @monikers = @_; + is_deeply ( + [ sort DBICNSTest::RtBug41083->sources ], + \@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'); + } +} + +{ + my $warnings; + eval { local $SIG{__WARN__} = sub { $warnings .= shift }; package DBICNSTest::RtBug41083; use base 'DBIx::Class::Schema'; __PACKAGE__->load_namespaces( - result_namespace => 'Schema_A', - resultset_namespace => 'ResultSet_A', - default_resultset_class => 'ResultSet' + result_namespace => 'Schema_A', + resultset_namespace => 'ResultSet_A', + default_resultset_class => 'ResultSet' ); -}; -ok(!$@) or diag $@; -ok(_chk_warning($warnings), 'expected no complaint'); + }; -eval { + ok(!$@) or diag $@; + ok(_chk_warning($warnings), 'expected no resultset complaint'); + ok(_chk_extra_sources_warning($warnings), 'expected no extra sources complaint') or diag($warnings); + + _verify_sources (qw/A A::Sub/); +} + +{ + my $warnings; + eval { local $SIG{__WARN__} = sub { $warnings .= shift }; package DBICNSTest::RtBug41083; use base 'DBIx::Class::Schema'; __PACKAGE__->load_namespaces( - result_namespace => 'Schema', - resultset_namespace => 'ResultSet', - default_resultset_class => 'ResultSet' + result_namespace => 'Schema', + resultset_namespace => 'ResultSet', + default_resultset_class => 'ResultSet' ); -}; -ok(!$@) or diag $@; -ok(_chk_warning($warnings), 'expected no complaint') or diag $warnings; + }; + ok(!$@) or diag $@; + ok(_chk_warning($warnings), 'expected no resultset complaint') or diag $warnings; + ok(_chk_extra_sources_warning($warnings), 'expected no extra sources complaint') or diag($warnings); + + _verify_sources (qw/A A::Sub Foo Foo::Sub/); +}