X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F05components.t;h=567bc1bc34cb8438ffdf0753d5f56ec5b5b2512b;hb=a79864b1fe3aa9f39f334a36d5e1bbdb563bcaf0;hp=fd0742f61e122488266096ba071f9a6f79afab2a;hpb=d6fd708475c878947014304386173d7a8b9f4698;p=dbsrgits%2FDBIx-Class.git diff --git a/t/05components.t b/t/05components.t index fd0742f..567bc1b 100644 --- a/t/05components.t +++ b/t/05components.t @@ -7,7 +7,7 @@ use Test::More; use lib qw(t/lib); use DBICTest::ForeignComponent; -plan tests => 2; +plan tests => 5; # Tests if foreign component was loaded by calling foreign's method ok( DBICTest::ForeignComponent->foreign_test_method, 'foreign component' ); @@ -15,6 +15,9 @@ ok( DBICTest::ForeignComponent->foreign_test_method, 'foreign component' ); # Test for inject_base to filter out duplicates { package DBICTest::_InjectBaseTest; use base qw/ DBIx::Class /; + package DBICTest::_InjectBaseTest::A; + package DBICTest::_InjectBaseTest::B; + package DBICTest::_InjectBaseTest::C; } DBICTest::_InjectBaseTest->inject_base( 'DBICTest::_InjectBaseTest', qw/ DBICTest::_InjectBaseTest::A @@ -31,3 +34,31 @@ is_deeply( \@DBICTest::_InjectBaseTest::ISA, /], 'inject_base filters duplicates' ); + +# Test for a warning with incorrect order in load_components +my @warnings = (); +{ + package A::Test; + our @ISA = 'DBIx::Class'; + { + local $SIG{__WARN__} = sub { push @warnings, shift}; + __PACKAGE__->load_components(qw(Core UTF8Columns)); + } +} +like( $warnings[0], qr/Core loaded before UTF8Columns/, + 'warning issued for incorrect order in load_components()' ); +is( scalar @warnings, 1, + 'only one warning issued for incorrect load_components call' ); + +# Test that no warning is issued for the correct order in load_components +{ + @warnings = (); + package B::Test; + our @ISA = 'DBIx::Class'; + { + local $SIG{__WARN__} = sub { push @warnings, shift }; + __PACKAGE__->load_components(qw(UTF8Columns Core)); + } +} +is( scalar @warnings, 0, + 'warning not issued for correct order in load_components()' );