X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F39load_namespaces_rt41083.t;h=f59d59758a3c2d8835a99c135eb6e1738ccced10;hb=c9087040faf8de638936b163c20f702a2878d7ab;hp=facb70fa2a1b5d48bde0495812f30bb3311efaae;hpb=e9c270c5e1e031c7ab0bd733304e8f240d05c5d2;p=dbsrgits%2FDBIx-Class.git diff --git a/t/39load_namespaces_rt41083.t b/t/39load_namespaces_rt41083.t index facb70f..f59d597 100644 --- a/t/39load_namespaces_rt41083.t +++ b/t/39load_namespaces_rt41083.t @@ -1,27 +1,65 @@ -#!/usr/bin/perl +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } use strict; use warnings; -use Test::More; -use lib 't/lib'; -plan tests => 2; +use DBICTest; # do not remove even though it is not used +use Test::More tests => 8; -my $warnings; -eval { +sub _chk_warning { + defined $_[0]? + $_[0] !~ qr/We found ResultSet class '([^']+)' for '([^']+)', but it seems that you had already set '([^']+)' to use '([^']+)' instead/ : + 1 +} + +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 $warnings; + eval { local $SIG{__WARN__} = sub { $warnings .= shift }; package DBICNSTest::RtBug41083; - use base 'DBIx::Class::Schema'; + use base 'DBICTest::BaseSchema'; __PACKAGE__->load_namespaces( - result_namespace => 'Schema', - resultset_namespace => 'ResultSet', - default_resultset_class => 'ResultSet' + result_namespace => 'Result_A', + resultset_namespace => 'ResultSet_A', + default_resultset_class => 'ResultSet' ); -}; -ok(!$@) or diag $@; -ok( - $warnings !~ - qr/We found ResultSet class '([^']+)' for '([^']+)', but it seems that you had already set '([^']+)' to use '([^']+)' instead/, - 'Proxy sub class did not generate an error' -); + }; + + 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 'DBICTest::BaseSchema'; + __PACKAGE__->load_namespaces( + default_resultset_class => 'ResultSet' + ); + }; + 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/); +}