-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize default condition order logic
Add default order and sorts unit tests
- Loading branch information
1 parent
7927a19
commit 18a9949
Showing
11 changed files
with
66 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/Unit/AdvancedSearchTrait/SortOutWhereConditionsProTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Tests\Unit\ConditionGeneratorTrait; | ||
|
||
use Illuminate\Support\Arr; | ||
use Tests\DBTestCase; | ||
use Tests\Utils\FakeRequest; | ||
use Tests\Utils\Models\User; | ||
|
||
class HandlePaginate extends DBTestCase | ||
{ | ||
public function test_sorts() | ||
{ | ||
$fakeRequest = new FakeRequest(); | ||
$conditions = $fakeRequest->getConditions([ | ||
'paginator' => [ | ||
'sorts' => [ | ||
'+rank', | ||
'-id', | ||
], | ||
], | ||
]); | ||
|
||
$this->assertEquals([ | ||
'rank' => 'asc', | ||
'id' => 'desc', | ||
], Arr::get($conditions, 'order')); | ||
} | ||
|
||
public function test_order() | ||
{ | ||
$fakeRequest = new FakeRequest(); | ||
$conditions = $fakeRequest->getConditions([]); | ||
|
||
$this->assertEquals([ | ||
'id' => 'asc', | ||
], Arr::get($conditions, 'order')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Tests\Utils; | ||
|
||
use MatrixLab\LaravelAdvancedSearch\ConditionsGeneratorTrait; | ||
|
||
class FakeRequest | ||
{ | ||
use ConditionsGeneratorTrait; | ||
|
||
protected function order() | ||
{ | ||
return '+id'; | ||
} | ||
} |