X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F39load_namespaces_3.t;h=1b63baa832332744dfa4f425fe1b50ec04b2312b;hb=aa072cab54f2e6af9a9db82b3cdec0ebb97717cc;hp=b066d648f6a959fd9aa252a5333003c508b30eec;hpb=f017c022afdd0b519a1be5eb749de6a1180c015f;p=dbsrgits%2FDBIx-Class.git diff --git a/t/39load_namespaces_3.t b/t/39load_namespaces_3.t index b066d64..1b63baa 100644 --- a/t/39load_namespaces_3.t +++ b/t/39load_namespaces_3.t @@ -1,41 +1,38 @@ -#!/usr/bin/perl +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } use strict; use warnings; use Test::More; +use Test::Exception; +use Test::Warn; -unshift(@INC, './t/lib'); - -plan tests => 10; - -my $warnings; -eval { - local $SIG{__WARN__} = sub { $warnings .= shift }; - package DBICNSTestOther; - use base qw/DBIx::Class::Schema/; - __PACKAGE__->load_namespaces( - source_namespace => [ '+DBICNSTest::Src', '+DBICNSTest::OtherSrc' ], - resultset_namespace => '+DBICNSTest::RSet', - result_namespace => '+DBICNSTest::Res' - ); -}; -ok(!$@) or diag $@; -like($warnings, qr/load_namespaces found ResultSet class C with no corresponding source-definition class/); -like($warnings, qr/load_namespaces found Result class C with no corresponding source-definition class/); + +use DBICTest; # do not remove even though it is not used + +lives_ok (sub { + warnings_exist ( sub { + package DBICNSTestOther; + use base qw/DBICTest::BaseSchema/; + __PACKAGE__->load_namespaces( + result_namespace => [ '+DBICNSTest::Rslt', '+DBICNSTest::OtherRslt' ], + resultset_namespace => '+DBICNSTest::RSet', + ); + }, + qr/load_namespaces found ResultSet class 'DBICNSTest::RSet::C' with no corresponding Result class/, + ); +}); my $source_a = DBICNSTestOther->source('A'); isa_ok($source_a, 'DBIx::Class::ResultSource::Table'); my $rset_a = DBICNSTestOther->resultset('A'); isa_ok($rset_a, 'DBICNSTest::RSet::A'); -my $resclass_a = DBICNSTestOther->resultset('A')->result_class; -is($resclass_a, 'DBICNSTest::Res::A'); my $source_b = DBICNSTestOther->source('B'); isa_ok($source_b, 'DBIx::Class::ResultSource::Table'); my $rset_b = DBICNSTestOther->resultset('B'); isa_ok($rset_b, 'DBIx::Class::ResultSet'); -my $resclass_b = DBICNSTestOther->resultset('B')->result_class; -is($resclass_b, 'DBICNSTest::Src::B'); my $source_d = DBICNSTestOther->source('D'); isa_ok($source_d, 'DBIx::Class::ResultSource::Table'); + +done_testing;