@@ -20,7 +20,7 @@ public function tearDown()
20
20
21
21
public function testInnerJoinT1 ()
22
22
{
23
- $ excpected = array (
23
+ $ expected = array (
24
24
array (
25
25
'left ' => array ('id ' => 1 , 'other ' => 'a ' ),
26
26
'right ' => array ('id ' => 'a ' , 'other ' => 1 )
@@ -42,15 +42,14 @@ function ($r1, $r2) {
42
42
return $ r1 ('other ' )->eq ($ r2 ('id ' ));
43
43
}
44
44
)
45
- ->orderBy (array (function ($ x ) { return $ x ("left " )->getField ("id " ); }, function ($ x ) { return $ x ("right " )->getField ("id " ); }))
46
45
->run ($ this ->conn );
47
46
48
- $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftAndRightId ($ res ));
47
+ $ this ->assertEquals ($ expected , $ this ->orderArrayByLeftAndRightId ($ res ));
49
48
}
50
49
51
50
public function testInnerJoinT2 ()
52
51
{
53
- $ excpected = array (
52
+ $ expected = array (
54
53
array (
55
54
'right ' => array ('id ' => 1 , 'other ' => 'a ' ),
56
55
'left ' => array ('id ' => 'a ' , 'other ' => 1 )
@@ -68,15 +67,14 @@ function ($r1, $r2) {
68
67
return $ r1 ('other ' )->eq ($ r2 ('id ' ));
69
68
}
70
69
)
71
- ->orderBy (array (function ($ x ) { return $ x ("left " )->getField ("id " ); }, function ($ x ) { return $ x ("right " )->getField ("id " ); }))
72
70
->run ($ this ->conn );
73
71
74
- $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftAndRightId ($ res ));
72
+ $ this ->assertEquals ($ expected , $ this ->orderArrayByLeftAndRightId ($ res ));
75
73
}
76
74
77
75
public function testOuterJoinT1 ()
78
76
{
79
- $ excpected = array (
77
+ $ expected = array (
80
78
array (
81
79
'left ' => array ('id ' => 1 , 'other ' => 'a ' ),
82
80
'right ' => array ('id ' => 'a ' , 'other ' => 1 )
@@ -98,15 +96,14 @@ function ($r1, $r2) {
98
96
return $ r1 ('other ' )->eq ($ r2 ('id ' ));
99
97
}
100
98
)
101
- ->orderBy (array (function ($ x ) { return $ x ("left " )->getField ("id " ); }, function ($ x ) { return $ x ("right " )->getField ("id " ); }))
102
99
->run ($ this ->conn );
103
100
104
- $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftAndRightId ($ res ));
101
+ $ this ->assertEquals ($ expected , $ this ->orderArrayByLeftAndRightId ($ res ));
105
102
}
106
103
107
104
public function testOuterJoinT2 ()
108
105
{
109
- $ excpected = array (
106
+ $ expected = array (
110
107
array (
111
108
'right ' => array ('id ' => 1 , 'other ' => 'a ' ),
112
109
'left ' => array ('id ' => 'a ' , 'other ' => 1 )
@@ -125,15 +122,14 @@ function ($r1, $r2) {
125
122
return $ r1 ('other ' )->eq ($ r2 ('id ' ));
126
123
}
127
124
)
128
- ->orderBy (array (function ($ x ) { return $ x ("left " )->getField ("id " ); }, function ($ x ) { return $ x ("right " )->getField ("id " ); }))
129
125
->run ($ this ->conn );
130
126
131
- $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftAndRightId ($ res ));
127
+ $ this ->assertEquals ($ expected , $ this ->orderArrayByLeftAndRightId ($ res ));
132
128
}
133
129
134
130
public function testEqJoinOther ()
135
131
{
136
- $ excpected = array (
132
+ $ expected = array (
137
133
array (
138
134
'left ' => array ('id ' => 1 , 'other ' => 'a ' ),
139
135
'right ' => array ('id ' => 'a ' , 'other ' => 1 )
@@ -150,15 +146,14 @@ public function testEqJoinOther()
150
146
151
147
$ res = $ this ->db ()->table ('t1 ' )
152
148
->eqJoin ('other ' , $ this ->db ()->table ('t2 ' ))
153
- ->orderBy (array (function ($ x ) { return $ x ("left " )->getField ("id " ); }, function ($ x ) { return $ x ("right " )->getField ("id " ); }))
154
149
->run ($ this ->conn );
155
150
156
- $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftAndRightId ($ res ));
151
+ $ this ->assertEquals ($ expected , $ this ->orderArrayByLeftAndRightId ($ res ));
157
152
}
158
153
159
154
public function testEqJoinId ()
160
155
{
161
- $ excpected = array (
156
+ $ expected = array (
162
157
array (
163
158
'left ' => array ('id ' => 1 , 'other ' => 'a ' ),
164
159
'right ' => array ('id ' => 'a ' , 'other ' => 1 )
@@ -171,15 +166,14 @@ public function testEqJoinId()
171
166
172
167
$ res = $ this ->db ()->table ('t1 ' )
173
168
->eqJoin ('id ' , $ this ->db ()->table ('t2 ' ), array ('index ' => 'other ' ))
174
- ->orderBy (array (function ($ x ) { return $ x ("left " )->getField ("id " ); }, function ($ x ) { return $ x ("right " )->getField ("id " ); }))
175
169
->run ($ this ->conn );
176
170
177
- $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftAndRightId ($ res ));
171
+ $ this ->assertEquals ($ expected , $ this ->orderArrayByLeftAndRightId ($ res ));
178
172
}
179
173
180
174
public function testEqJoinFunc ()
181
175
{
182
- $ excpected = array (
176
+ $ expected = array (
183
177
array (
184
178
'left ' => array ('id ' => 1 , 'other ' => 'a ' ),
185
179
'right ' => array ('id ' => 'a ' , 'other ' => 1 )
@@ -198,31 +192,29 @@ public function testEqJoinFunc()
198
192
->eqJoin (function ($ x ) {
199
193
return $ x ('other ' );
200
194
}, $ this ->db ()->table ('t2 ' ))
201
- ->orderBy (array (function ($ x ) { return $ x ("left " )->getField ("id " ); }, function ($ x ) { return $ x ("right " )->getField ("id " ); }))
202
195
->run ($ this ->conn );
203
196
204
- $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftAndRightId ($ res ));
197
+ $ this ->assertEquals ($ expected , $ this ->orderArrayByLeftAndRightId ($ res ));
205
198
}
206
199
207
200
public function testEqJoinZip ()
208
201
{
209
- $ excpected = array (
202
+ $ expected = array (
210
203
array ('id ' => 'a ' , 'other ' => 1 ),
211
204
array ('id ' => 'b ' , 'other ' => 1 )
212
205
);
213
206
214
207
$ res = $ this ->db ()->table ('t1 ' )
215
208
->eqJoin ('id ' , $ this ->db ()->table ('t2 ' ), array ('index ' => 'other ' ))
216
209
->zip ()
217
- ->orderBy ("id " )
218
210
->run ($ this ->conn );
219
211
220
- $ this ->assertEquals ($ excpected , $ this ->orderArrayById ($ res ));
212
+ $ this ->assertEquals ($ expected , $ this ->orderArrayById ($ res ));
221
213
}
222
214
223
215
protected function orderArrayByLeftAndRightId ($ data )
224
216
{
225
- $ data = $ this ->toArray ($ data );
217
+ $ data = $ this ->toArray ($ data-> toArray () );
226
218
usort ($ data , function ($ a , $ b ) {
227
219
if ($ a ['left ' ]['id ' ] == $ b ['left ' ]['id ' ]) {
228
220
return $ a ['right ' ]['id ' ] > $ b ['right ' ]['id ' ];
@@ -235,7 +227,7 @@ protected function orderArrayByLeftAndRightId($data)
235
227
236
228
protected function orderArrayById ($ data )
237
229
{
238
- $ data = $ this ->toArray ($ data );
230
+ $ data = $ this ->toArray ($ data-> toArray () );
239
231
usort ($ data , function ($ a , $ b ) {
240
232
return strcmp ($ a ['id ' ], $ b ['id ' ]);
241
233
});
0 commit comments