Sketches of tests that should ultimately pass
[dbsrgits/DBIx-Class.git] / t / prefetch / _internals.t
CommitLineData
9f6555d3 1use strict;
2use warnings;
3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7
8my $schema = DBICTest->init_schema(no_deploy => 1);
9
10
11my $irow = $schema->source ('Artwork')->_parse_row (
12 {
13 'cd_id' => '1',
14
15 'artwork_to_artist.artist_id' => '2',
16 'artwork_to_artist.artwork_cd_id' => '1',
17
18 'cd.artist' => '1',
19 'cd.cdid' => '1',
20 'cd.title' => 'Spoonful of bees',
21
22 'cd.artist.artistid' => '1',
23 'cd.artist.name' => 'Caterwauler McCrae',
24 },
25 'will collapse'
26);
27
28is_deeply (
29 $irow,
30 [
31 {
32 'cd_id' => '1'
33 },
34 {
35 'artwork_to_artist' => [
36 [
37 {
38 'artist_id' => '2',
39 'artwork_cd_id' => '1'
40 }
41 ]
42 ],
43
44 'cd' => [
45 {
46 'artist' => '1',
47 'cdid' => '1',
48 'title' => 'Spoonful of bees',
49 },
50 {
51 'artist' => [
52 {
53 'artistid' => '1',
54 'name' => 'Caterwauler McCrae',
55 }
56 ]
57 }
58 ]
59 }
60 ],
61 '_parse_row works as expected with expected collapse',
62);
63
64$irow = $schema->source ('Artist')->_parse_row (
65 {
66 'name' => 'Caterwauler McCrae',
67 'cds.tracks.cd' => '3',
68 'cds.tracks.title' => 'Fowlin',
69 'cds.tracks.cd_single.title' => 'Awesome single',
70 }
71);
72is_deeply (
73 $irow,
74 [
75 {
76 'name' => 'Caterwauler McCrae'
77 },
78 {
79 'cds' => [
80 {},
81 {
82 'tracks' => [
83 {
84 'cd' => '3',
85 'title' => 'Fowlin'
86 },
87 {
88 'cd_single' => [
89 {
90 title => 'Awesome single',
91 },
92 ],
93 },
94 ]
95 }
96 ]
97 }
98 ],
99 '_parse_row works over missing joins without collapse',
100);
101
102done_testing;