mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-17 09:52:27 +08:00
Sorting: Fixes during testing of sort rules
- Fixed name numeric sorting not working as expected due to bad comparison. - Added name numeric desc operation option. - Added test to ensure each operating has a comparison function.
This commit is contained in:
@ -5,6 +5,7 @@ namespace Tests\Sorting;
|
||||
use BookStack\Activity\ActivityType;
|
||||
use BookStack\Entities\Models\Book;
|
||||
use BookStack\Sorting\SortRule;
|
||||
use BookStack\Sorting\SortRuleOperation;
|
||||
use Tests\Api\TestsApi;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -202,7 +203,8 @@ class SortRuleTest extends TestCase
|
||||
"20 - Milk",
|
||||
];
|
||||
|
||||
foreach ($namesToAdd as $name) {
|
||||
$reverseNamesToAdd = array_reverse($namesToAdd);
|
||||
foreach ($reverseNamesToAdd as $name) {
|
||||
$this->actingAsApiEditor()->post("/api/pages", [
|
||||
'book_id' => $book->id,
|
||||
'name' => $name,
|
||||
@ -218,4 +220,14 @@ class SortRuleTest extends TestCase
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_each_sort_rule_operation_has_a_comparison_function()
|
||||
{
|
||||
$operations = SortRuleOperation::cases();
|
||||
|
||||
foreach ($operations as $operation) {
|
||||
$comparisonFunc = $operation->getSortFunction();
|
||||
$this->assertIsCallable($comparisonFunc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user