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