X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F39load_namespaces_rt41083.t;h=79c9c7a31f49355d5ef68a595f856cc02313f6a0;hb=da89304fa29f8fd18d235d120ccbea7d2cfbecdf;hp=3f037a8df901d5bd6b0cde48997e7ff92b16adcc;hpb=c24e75ad97524ff3d75880c6d604cbad3dbd57c2;p=dbsrgits%2FDBIx-Class.git diff --git a/t/39load_namespaces_rt41083.t b/t/39load_namespaces_rt41083.t index 3f037a8..79c9c7a 100644 --- a/t/39load_namespaces_rt41083.t +++ b/t/39load_namespaces_rt41083.t @@ -1,12 +1,9 @@ -#!/usr/bin/perl - use strict; use warnings; -use Test::More; use lib 't/lib'; - -plan tests => 6; +use DBICTest; # do not remove even though it is not used +use Test::More tests => 8; sub _chk_warning { defined $_[0]? @@ -19,33 +16,50 @@ sub _chk_extra_sources_warning { defined $_[0]? $_[0] !~ /$p/ : 1; } -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' - ); -}; -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); -undef $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' +sub _verify_sources { + my @monikers = @_; + is_deeply ( + [ sort DBICNSTest::RtBug41083->sources ], + \@monikers, + 'List of resultsource registrations', ); -}; -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); -undef $warnings; +} + +{ + 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' + ); + }; + + 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' + ); + }; + 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/); +}