Fix tests failing due to unspecified resultset retrieval order
[dbsrgits/DBIx-Class.git] / t / prefetch / restricted_children_set.t
CommitLineData
574dd7c9 1use strict;
2use warnings;
3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7
8my $schema = DBICTest->init_schema();
9
10my $cds_rs = $schema->resultset('CD')->search(
11 [
12 {
13 'me.title' => "Caterwaulin' Blues",
14 'cds.title' => { '!=' => 'Forkful of bees' }
15 },
16 {
17 'me.title' => { '!=', => "Caterwaulin' Blues" },
18 'cds.title' => 'Forkful of bees'
19 },
20 ],
21 {
fb88ca2c 22 order_by => [qw(me.cdid cds.title)],
574dd7c9 23 prefetch => { artist => 'cds' },
24 result_class => 'DBIx::Class::ResultClass::HashRefInflator',
25 },
26);
27
28is_deeply [ $cds_rs->all ], [
29 {
30 'single_track' => undef,
31 'cdid' => '1',
32 'artist' => {
33 'cds' => [
34 {
35 'single_track' => undef,
36 'artist' => '1',
37 'cdid' => '2',
38 'title' => 'Forkful of bees',
39 'genreid' => undef,
40 'year' => '2001'
41 },
42 ],
43 'artistid' => '1',
44 'charfield' => undef,
45 'name' => 'Caterwauler McCrae',
46 'rank' => '13'
47 },
48 'title' => 'Spoonful of bees',
49 'year' => '1999',
50 'genreid' => '1'
51 },
52 {
53 'single_track' => undef,
54 'cdid' => '2',
55 'artist' => {
56 'cds' => [
57 {
58 'single_track' => undef,
59 'artist' => '1',
60 'cdid' => '2',
61 'title' => 'Forkful of bees',
62 'genreid' => undef,
63 'year' => '2001'
64 },
65 ],
66 'artistid' => '1',
67 'charfield' => undef,
68 'name' => 'Caterwauler McCrae',
69 'rank' => '13'
70 },
71 'title' => 'Forkful of bees',
72 'year' => '2001',
73 'genreid' => undef
74 },
75 {
76 'single_track' => undef,
77 'cdid' => '3',
78 'artist' => {
79 'cds' => [
80 {
81 'single_track' => undef,
82 'artist' => '1',
83 'cdid' => '3',
84 'title' => 'Caterwaulin\' Blues',
85 'genreid' => undef,
86 'year' => '1997'
87 },
88 {
89 'single_track' => undef,
90 'artist' => '1',
91 'cdid' => '1',
92 'title' => 'Spoonful of bees',
93 'genreid' => '1',
94 'year' => '1999'
95 }
96 ],
97 'artistid' => '1',
98 'charfield' => undef,
99 'name' => 'Caterwauler McCrae',
100 'rank' => '13'
101 },
102 'title' => 'Caterwaulin\' Blues',
103 'year' => '1997',
104 'genreid' => undef
105 }
106], 'multi-level prefetch with restrictions ok';
107
108done_testing;