|
24 | 24 | use SortDirection; |
25 | 25 | use stdClass; |
26 | 26 |
|
| 27 | +use function class_exists; |
27 | 28 | use function collect; |
28 | 29 | use function method_exists; |
29 | 30 | use function now; |
@@ -567,20 +568,22 @@ function (Builder $builder) { |
567 | 568 | fn (Builder $builder) => $builder->orderByDesc('email'), |
568 | 569 | ]; |
569 | 570 |
|
570 | | - yield 'orderBy SortDirection::Ascending' => [ |
571 | | - ['find' => [[], ['sort' => ['email' => 1]]]], |
572 | | - fn (Builder $builder) => $builder->orderBy('email', SortDirection::Ascending), |
573 | | - ]; |
| 571 | + if (class_exists(SortDirection::class)) { |
| 572 | + yield 'orderBy SortDirection::Ascending' => [ |
| 573 | + ['find' => [[], ['sort' => ['email' => 1]]]], |
| 574 | + fn (Builder $builder) => $builder->orderBy('email', SortDirection::Ascending), |
| 575 | + ]; |
574 | 576 |
|
575 | | - yield 'orderBy SortDirection::Descending' => [ |
576 | | - ['find' => [[], ['sort' => ['email' => -1]]]], |
577 | | - fn (Builder $builder) => $builder->orderBy('email', SortDirection::Descending), |
578 | | - ]; |
| 577 | + yield 'orderBy SortDirection::Descending' => [ |
| 578 | + ['find' => [[], ['sort' => ['email' => -1]]]], |
| 579 | + fn (Builder $builder) => $builder->orderBy('email', SortDirection::Descending), |
| 580 | + ]; |
579 | 581 |
|
580 | | - yield 'orderBy SortDirection on natural' => [ |
581 | | - ['find' => [[], ['sort' => ['$natural' => -1]]]], |
582 | | - fn (Builder $builder) => $builder->orderBy('natural', SortDirection::Descending), |
583 | | - ]; |
| 582 | + yield 'orderBy SortDirection on natural' => [ |
| 583 | + ['find' => [[], ['sort' => ['$natural' => -1]]]], |
| 584 | + fn (Builder $builder) => $builder->orderBy('natural', SortDirection::Descending), |
| 585 | + ]; |
| 586 | + } |
584 | 587 |
|
585 | 588 | /** @see DatabaseQueryBuilderTest::testReorder() */ |
586 | 589 | yield 'reorder reset' => [ |
|
0 commit comments