Fixed _register_source to not produce 'register_extra_source' warnings
[dbsrgits/DBIx-Class.git] / t / 39load_namespaces_rt41083.t
CommitLineData
e9c270c5 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use Test::More;
6
7use lib 't/lib';
8
55f02c6d 9plan tests => 6;
e9c270c5 10
45f8858e 11sub _chk_warning {
12 defined $_[0]?
13 $_[0] !~ qr/We found ResultSet class '([^']+)' for '([^']+)', but it seems that you had already set '([^']+)' to use '([^']+)' instead/ :
14 1
15}
16
55f02c6d 17sub _chk_extra_sources_warning {
18 my $p = qr/already has a source, use register_extra_source for additional sources/;
19 defined $_[0]? $_[0] !~ /$p/ : 1;
20}
21
e9c270c5 22my $warnings;
23eval {
24 local $SIG{__WARN__} = sub { $warnings .= shift };
25 package DBICNSTest::RtBug41083;
26 use base 'DBIx::Class::Schema';
27 __PACKAGE__->load_namespaces(
45f8858e 28 result_namespace => 'Schema_A',
29 resultset_namespace => 'ResultSet_A',
30 default_resultset_class => 'ResultSet'
31 );
32};
33ok(!$@) or diag $@;
55f02c6d 34ok(_chk_warning($warnings), 'expected no resultset complaint');
40da0990 35ok(_chk_extra_sources_warning($warnings), 'expected no extra sources complaint') or diag($warnings);
55f02c6d 36undef $warnings;
45f8858e 37
38eval {
39 local $SIG{__WARN__} = sub { $warnings .= shift };
40 package DBICNSTest::RtBug41083;
41 use base 'DBIx::Class::Schema';
42 __PACKAGE__->load_namespaces(
e9c270c5 43 result_namespace => 'Schema',
44 resultset_namespace => 'ResultSet',
45 default_resultset_class => 'ResultSet'
46 );
47};
48ok(!$@) or diag $@;
55f02c6d 49ok(_chk_warning($warnings), 'expected no resultset complaint') or diag $warnings;
40da0990 50ok(_chk_extra_sources_warning($warnings), 'expected no extra sources complaint') or diag($warnings);
55f02c6d 51undef $warnings;