X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F05components.t;h=303f0285876b693ec573c927a8aa52f8f3c91112;hb=f2b70f86c9c44eb3367bd2d4d629f7e201032652;hp=57bebd510a0227afd17d6858e5ca2be965d5d517;hpb=6db94aca366e5734230b70b00cad3387ffac9e17;p=dbsrgits%2FDBIx-Class.git diff --git a/t/05components.t b/t/05components.t index 57bebd5..303f028 100644 --- a/t/05components.t +++ b/t/05components.t @@ -7,8 +7,60 @@ use Test::More; use lib qw(t/lib); use DBICTest::ForeignComponent; -plan tests => 1; +plan tests => 6; # Tests if foreign component was loaded by calling foreign's method 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 + DBICTest::_InjectBaseTest::B + DBICTest::_InjectBaseTest::B + DBICTest::_InjectBaseTest::C +/); +is_deeply( \@DBICTest::_InjectBaseTest::ISA, + [qw/ + DBICTest::_InjectBaseTest::A + DBICTest::_InjectBaseTest::B + DBICTest::_InjectBaseTest::C + DBIx::Class + /], + '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()' ); + +use_ok('DBIx::Class::AccessorGroup');