Institute a central "load this first in testing" package
[dbsrgits/DBIx-Class.git] / t / 39load_namespaces_rt41083.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
f5ceba67 3use strict;
4use warnings;
f5ceba67 5
c0329273 6
8273e845 7use DBICTest; # do not remove even though it is not used
45593952 8use Test::More tests => 8;
f5ceba67 9
f5ceba67 10sub _chk_warning {
11 defined $_[0]?
12 $_[0] !~ qr/We found ResultSet class '([^']+)' for '([^']+)', but it seems that you had already set '([^']+)' to use '([^']+)' instead/ :
13 1
14}
15
16sub _chk_extra_sources_warning {
17 my $p = qr/already has a source, use register_extra_source for additional sources/;
18 defined $_[0]? $_[0] !~ /$p/ : 1;
19}
20
21sub _verify_sources {
22 my @monikers = @_;
23 is_deeply (
24 [ sort DBICNSTest::RtBug41083->sources ],
25 \@monikers,
26 'List of resultsource registrations',
27 );
f5ceba67 28}
29
30{
31 my $warnings;
32 eval {
33 local $SIG{__WARN__} = sub { $warnings .= shift };
34 package DBICNSTest::RtBug41083;
35 use base 'DBIx::Class::Schema';
36 __PACKAGE__->load_namespaces(
6cedc92e 37 result_namespace => 'Result_A',
f5ceba67 38 resultset_namespace => 'ResultSet_A',
39 default_resultset_class => 'ResultSet'
40 );
41 };
42
43 ok(!$@) or diag $@;
44 ok(_chk_warning($warnings), 'expected no resultset complaint');
45 ok(_chk_extra_sources_warning($warnings), 'expected no extra sources complaint') or diag($warnings);
46
47 _verify_sources (qw/A A::Sub/);
48}
49
50{
51 my $warnings;
52 eval {
53 local $SIG{__WARN__} = sub { $warnings .= shift };
54 package DBICNSTest::RtBug41083;
55 use base 'DBIx::Class::Schema';
56 __PACKAGE__->load_namespaces(
f5ceba67 57 default_resultset_class => 'ResultSet'
58 );
59 };
60 ok(!$@) or diag $@;
61 ok(_chk_warning($warnings), 'expected no resultset complaint') or diag $warnings;
62 ok(_chk_extra_sources_warning($warnings), 'expected no extra sources complaint') or diag($warnings);
63
64 _verify_sources (qw/A A::Sub Foo Foo::Sub/);
65}