Commit | Line | Data |
f5ceba67 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
f5ceba67 |
5 | |
6 | use lib 't/lib'; |
45593952 |
7 | use Test::More tests => 8; |
f5ceba67 |
8 | |
03e3321a |
9 | plan tests => 8; |
f5ceba67 |
10 | |
11 | sub _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 | |
17 | sub _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 | |
22 | sub _verify_sources { |
23 | my @monikers = @_; |
24 | is_deeply ( |
25 | [ sort DBICNSTest::RtBug41083->sources ], |
26 | \@monikers, |
27 | 'List of resultsource registrations', |
28 | ); |
f5ceba67 |
29 | } |
30 | |
31 | { |
32 | my $warnings; |
33 | eval { |
34 | local $SIG{__WARN__} = sub { $warnings .= shift }; |
35 | package DBICNSTest::RtBug41083; |
36 | use base 'DBIx::Class::Schema'; |
37 | __PACKAGE__->load_namespaces( |
38 | result_namespace => 'Schema_A', |
39 | resultset_namespace => 'ResultSet_A', |
40 | default_resultset_class => 'ResultSet' |
41 | ); |
42 | }; |
43 | |
44 | ok(!$@) or diag $@; |
45 | ok(_chk_warning($warnings), 'expected no resultset complaint'); |
46 | ok(_chk_extra_sources_warning($warnings), 'expected no extra sources complaint') or diag($warnings); |
47 | |
48 | _verify_sources (qw/A A::Sub/); |
49 | } |
50 | |
51 | { |
52 | my $warnings; |
53 | eval { |
54 | local $SIG{__WARN__} = sub { $warnings .= shift }; |
55 | package DBICNSTest::RtBug41083; |
56 | use base 'DBIx::Class::Schema'; |
57 | __PACKAGE__->load_namespaces( |
58 | result_namespace => 'Schema', |
59 | resultset_namespace => 'ResultSet', |
60 | default_resultset_class => 'ResultSet' |
61 | ); |
62 | }; |
63 | ok(!$@) or diag $@; |
64 | ok(_chk_warning($warnings), 'expected no resultset complaint') or diag $warnings; |
65 | ok(_chk_extra_sources_warning($warnings), 'expected no extra sources complaint') or diag($warnings); |
66 | |
67 | _verify_sources (qw/A A::Sub Foo Foo::Sub/); |
68 | } |