Institute a central "load this first in testing" package
[dbsrgits/DBIx-Class.git] / xt / extra / c3_mro.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
e8b77df6 3use warnings;
e4c24739 4use strict;
e8b77df6 5
6use Test::More;
e4c24739 7
c0329273 8
87bf71d5 9use DBICTest; # do not remove even though it is not used (pulls in MRO::Compat if needed)
d8190011 10
e4c24739 11{
e8b77df6 12 package AAA;
e4c24739 13
e8b77df6 14 use base "DBIx::Class::Core";
15}
e4c24739 16
e8b77df6 17{
18 package BBB;
e4c24739 19
e8b77df6 20 use base 'AAA';
e4c24739 21
e8b77df6 22 #Injecting a direct parent.
23 __PACKAGE__->inject_base( __PACKAGE__, 'AAA' );
24}
e4c24739 25
e8b77df6 26{
27 package CCC;
e4c24739 28
e8b77df6 29 use base 'AAA';
e4c24739 30
e8b77df6 31 #Injecting an indirect parent.
32 __PACKAGE__->inject_base( __PACKAGE__, 'DBIx::Class::Core' );
e4c24739 33}
34
4f507947 35eval { mro::get_linear_isa('BBB'); };
e4c24739 36ok (! $@, "Correctly skipped injecting a direct parent of class BBB");
37
4f507947 38eval { mro::get_linear_isa('CCC'); };
e4c24739 39ok (! $@, "Correctly skipped injecting an indirect parent of class BBB");
e8b77df6 40
41use DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server;
e8b77df6 42
43is_deeply (
44 mro::get_linear_isa('DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server'),
45 [qw/
46 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server
47 DBIx::Class::Storage::DBI::Sybase
48 DBIx::Class::Storage::DBI::MSSQL
49 DBIx::Class::Storage::DBI::UniqueIdentifier
fabbd5cc 50 DBIx::Class::Storage::DBI::IdentityInsert
e8b77df6 51 DBIx::Class::Storage::DBI
52 DBIx::Class::Storage::DBIHacks
53 DBIx::Class::Storage
54 DBIx::Class
55 DBIx::Class::Componentised
56 Class::C3::Componentised
db29433c 57 DBIx::Class::AccessorGroup
e8b77df6 58 Class::Accessor::Grouped
59 /],
60 'Correctly ordered ISA of DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server'
61);
62
87bf71d5 63my $storage = DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server->new;
c1e5a9ac 64$storage->connect_info(['dbi:SQLite::memory:']); # determine_driver's init() connects for this subclass
87bf71d5 65$storage->_determine_driver;
e8b77df6 66is (
87bf71d5 67 $storage->can('sql_limit_dialect'),
68 'DBIx::Class::Storage::DBI::MSSQL'->can('sql_limit_dialect'),
e8b77df6 69 'Correct method picked'
70);
71
750a4ad2 72if ( "$]" >= 5.010 ) {
87bf71d5 73 ok (! $INC{'Class/C3.pm'}, 'No Class::C3 loaded on perl 5.10+');
74
75 # Class::C3::Componentised loads MRO::Compat unconditionally to satisfy
76 # the assumption that once Class::C3::X is loaded, so is Class::C3
77 #ok (! $INC{'MRO/Compat.pm'}, 'No MRO::Compat loaded on perl 5.10+');
78}
79
e8b77df6 80done_testing;