Commit | Line | Data |
c0329273 |
1 | BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } |
2 | |
f5ceba67 |
3 | use strict; |
4 | use warnings; |
f5ceba67 |
5 | |
c0329273 |
6 | |
8273e845 |
7 | use DBICTest; # do not remove even though it is not used |
45593952 |
8 | use Test::More tests => 8; |
f5ceba67 |
9 | |
f5ceba67 |
10 | sub _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 | |
16 | sub _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 | |
21 | sub _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 | } |