You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/php/ORM/SQLSelectTest.php
+51-7Lines changed: 51 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -197,17 +197,61 @@ public function testCanSortBy()
197
197
$this->assertTrue($query->canSortBy('Name'));
198
198
}
199
199
200
+
publicstaticfunctionprovideAddOrderBy(): array
201
+
{
202
+
return [
203
+
'single basic clause' => [
204
+
'orderByClauses' => [
205
+
['Title'],
206
+
],
207
+
'expectedQuery' => 'SELECT ID, Title FROM Page ORDER BY Title ASC',
208
+
],
209
+
'single basic clause with order' => [
210
+
'orderByClauses' => [
211
+
['Title', 'desc'],
212
+
],
213
+
'expectedQuery' => 'SELECT ID, Title FROM Page ORDER BY Title DESC',
214
+
],
215
+
'single basic clause with order in first arg' => [
216
+
'orderByClauses' => [
217
+
['Title desc'],
218
+
],
219
+
'expectedQuery' => 'SELECT ID, Title FROM Page ORDER BY Title DESC',
220
+
],
221
+
'single clause column name ends with "asc"' => [
222
+
'orderByClauses' => [
223
+
['Flasc', 'DESC'],
224
+
],
225
+
'expectedQuery' => 'SELECT ID, Title FROM Page ORDER BY Flasc DESC',
226
+
],
227
+
'multiple clauses' => [
228
+
'orderByClauses' => [
229
+
['ID'],
230
+
['Title', 'DESC'],
231
+
],
232
+
'expectedQuery' => 'SELECT ID, Title FROM Page ORDER BY ID ASC, Title DESC',
233
+
],
234
+
'custom sort columns' => [
235
+
'orderByClauses' => [
236
+
['(ID % 2) = 0', 'ASC'],
237
+
['ID > 50', 'ASC'],
238
+
],
239
+
'expectedQuery' => 'SELECT ID, Title, (ID % 2) = 0 AS "_SortColumn0", ID > 50 AS "_SortColumn1" FROM Page ORDER BY "_SortColumn0" ASC, "_SortColumn1" ASC',
0 commit comments