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