Commit | Line | Data |
1d78a406 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | use Test::More; |
1d78a406 |
8 | |
aab9e887 |
9 | plan tests => 15; |
1d78a406 |
10 | |
11 | my $schema = DBICTest->init_schema(); |
12 | my $rs = $schema->resultset( 'CD' ); |
13 | |
14 | { |
15 | my $a = 'artist'; |
16 | my $b = 'cd'; |
17 | my $expected = [ 'artist', 'cd' ]; |
18 | my $result = $rs->_merge_attr($a, $b); |
19 | is_deeply( $result, $expected ); |
20 | } |
21 | |
22 | { |
23 | my $a = [ 'artist' ]; |
24 | my $b = [ 'cd' ]; |
25 | my $expected = [ 'artist', 'cd' ]; |
26 | my $result = $rs->_merge_attr($a, $b); |
27 | is_deeply( $result, $expected ); |
28 | } |
29 | |
30 | { |
31 | my $a = [ 'artist', 'cd' ]; |
32 | my $b = [ 'cd' ]; |
33 | my $expected = [ 'artist', 'cd' ]; |
34 | my $result = $rs->_merge_attr($a, $b); |
35 | is_deeply( $result, $expected ); |
36 | } |
37 | |
38 | { |
39 | my $a = [ 'artist', 'artist' ]; |
40 | my $b = [ 'artist', 'cd' ]; |
41 | my $expected = [ 'artist', 'artist', 'cd' ]; |
42 | my $result = $rs->_merge_attr($a, $b); |
43 | is_deeply( $result, $expected ); |
44 | } |
45 | |
46 | { |
47 | my $a = [ 'artist', 'cd' ]; |
48 | my $b = [ 'artist', 'artist' ]; |
49 | my $expected = [ 'artist', 'cd', 'artist' ]; |
50 | my $result = $rs->_merge_attr($a, $b); |
51 | is_deeply( $result, $expected ); |
52 | } |
53 | |
54 | { |
aab9e887 |
55 | my $a = [ 'twokeys' ]; |
56 | my $b = [ 'cds', 'cds' ]; |
57 | my $expected = [ 'twokeys', 'cds', 'cds' ]; |
58 | my $result = $rs->_merge_attr($a, $b); |
59 | is_deeply( $result, $expected ); |
60 | } |
61 | |
62 | { |
1d78a406 |
63 | my $a = [ 'artist', 'cd', { 'artist' => 'manager' } ]; |
64 | my $b = 'artist'; |
65 | my $expected = [ 'artist', 'cd', { 'artist' => 'manager' } ]; |
66 | my $result = $rs->_merge_attr($a, $b); |
67 | is_deeply( $result, $expected ); |
68 | } |
69 | |
70 | { |
71 | my $a = [ 'artist', 'cd', { 'artist' => 'manager' } ]; |
72 | my $b = [ 'artist', 'cd' ]; |
73 | my $expected = [ 'artist', 'cd', { 'artist' => 'manager' } ]; |
74 | my $result = $rs->_merge_attr($a, $b); |
75 | is_deeply( $result, $expected ); |
76 | } |
77 | |
78 | { |
79 | my $a = [ 'artist', 'cd', { 'artist' => 'manager' } ]; |
80 | my $b = { 'artist' => 'manager' }; |
81 | my $expected = [ 'artist', 'cd', { 'artist' => [ 'manager' ] } ]; |
82 | my $result = $rs->_merge_attr($a, $b); |
83 | is_deeply( $result, $expected ); |
84 | } |
85 | |
86 | { |
87 | my $a = [ 'artist', 'cd', { 'artist' => 'manager' } ]; |
88 | my $b = { 'artist' => 'agent' }; |
89 | my $expected = [ { 'artist' => 'agent' }, 'cd', { 'artist' => 'manager' } ]; |
90 | my $result = $rs->_merge_attr($a, $b); |
91 | is_deeply( $result, $expected ); |
92 | } |
93 | |
94 | { |
95 | my $a = [ 'artist', 'cd', { 'artist' => 'manager' } ]; |
96 | my $b = { 'artist' => { 'manager' => 'artist' } }; |
97 | my $expected = [ 'artist', 'cd', { 'artist' => [ { 'manager' => 'artist' } ] } ]; |
98 | my $result = $rs->_merge_attr($a, $b); |
99 | is_deeply( $result, $expected ); |
100 | } |
101 | |
102 | { |
103 | my $a = [ 'artist', 'cd', { 'artist' => 'manager' } ]; |
104 | my $b = { 'artist' => { 'manager' => [ 'artist', 'label' ] } }; |
105 | my $expected = [ 'artist', 'cd', { 'artist' => [ { 'manager' => [ 'artist', 'label' ] } ] } ]; |
106 | my $result = $rs->_merge_attr($a, $b); |
107 | is_deeply( $result, $expected ); |
108 | } |
109 | |
110 | { |
111 | my $a = [ 'artist', 'cd', { 'artist' => 'manager' } ]; |
112 | my $b = { 'artist' => { 'tour_manager' => [ 'venue', 'roadie' ] } }; |
113 | my $expected = [ { 'artist' => { 'tour_manager' => [ 'venue', 'roadie' ] } }, 'cd', { 'artist' => 'manager' } ]; |
114 | my $result = $rs->_merge_attr($a, $b); |
115 | is_deeply( $result, $expected ); |
116 | } |
117 | |
118 | { |
119 | my $a = [ 'artist', 'cd' ]; |
120 | my $b = { 'artist' => { 'tour_manager' => [ 'venue', 'roadie' ] } }; |
121 | my $expected = [ { 'artist' => { 'tour_manager' => [ 'venue', 'roadie' ] } }, 'cd' ]; |
122 | my $result = $rs->_merge_attr($a, $b); |
123 | is_deeply( $result, $expected ); |
124 | } |
125 | |
126 | { |
127 | my $a = [ { 'artist' => 'manager' }, 'cd' ]; |
128 | my $b = [ 'artist', { 'artist' => 'manager' } ]; |
129 | my $expected = [ { 'artist' => 'manager' }, 'cd', { 'artist' => 'manager' } ]; |
130 | my $result = $rs->_merge_attr($a, $b); |
131 | is_deeply( $result, $expected ); |
132 | } |
133 | |
134 | |
135 | 1; |