Update Changes
[dbsrgits/DBIx-Class-Historic.git] / t / 05components.t
CommitLineData
6db94aca 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use Test::More;
6
7use lib qw(t/lib);
8use DBICTest::ForeignComponent;
9
fe0e9f67 10plan tests => 6;
6db94aca 11
12# Tests if foreign component was loaded by calling foreign's method
13ok( DBICTest::ForeignComponent->foreign_test_method, 'foreign component' );
14
d6fd7084 15# Test for inject_base to filter out duplicates
16{ package DBICTest::_InjectBaseTest;
17 use base qw/ DBIx::Class /;
eb47985e 18 package DBICTest::_InjectBaseTest::A;
19 package DBICTest::_InjectBaseTest::B;
20 package DBICTest::_InjectBaseTest::C;
d6fd7084 21}
22DBICTest::_InjectBaseTest->inject_base( 'DBICTest::_InjectBaseTest', qw/
23 DBICTest::_InjectBaseTest::A
24 DBICTest::_InjectBaseTest::B
25 DBICTest::_InjectBaseTest::B
26 DBICTest::_InjectBaseTest::C
27/);
28is_deeply( \@DBICTest::_InjectBaseTest::ISA,
29 [qw/
30 DBICTest::_InjectBaseTest::A
31 DBICTest::_InjectBaseTest::B
32 DBICTest::_InjectBaseTest::C
33 DBIx::Class
34 /],
35 'inject_base filters duplicates'
36);
df88a29c 37
38# Test for a warning with incorrect order in load_components
39my @warnings = ();
40{
41 package A::Test;
42 our @ISA = 'DBIx::Class';
43 {
44 local $SIG{__WARN__} = sub { push @warnings, shift};
45 __PACKAGE__->load_components(qw(Core UTF8Columns));
46 }
47}
48like( $warnings[0], qr/Core loaded before UTF8Columns/,
49 'warning issued for incorrect order in load_components()' );
50is( scalar @warnings, 1,
51 'only one warning issued for incorrect load_components call' );
52
53# Test that no warning is issued for the correct order in load_components
54{
55 @warnings = ();
56 package B::Test;
57 our @ISA = 'DBIx::Class';
58 {
59 local $SIG{__WARN__} = sub { push @warnings, shift };
60 __PACKAGE__->load_components(qw(UTF8Columns Core));
61 }
62}
63is( scalar @warnings, 0,
64 'warning not issued for correct order in load_components()' );
fe0e9f67 65
66use_ok('DBIx::Class::AccessorGroup');