]> BookStack Code Mirror - bookstack/blobdiff - tests/Sorting/SortRuleTest.php
Sorting: Fixes during testing of sort rules
[bookstack] / tests / Sorting / SortRuleTest.php
index 10c7bc17d3e33c70c16fd39c484bb25e53ad974a..85b3d7991c44af7e89cd89aa21ffab0c53f4b950 100644 (file)
@@ -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);
+        }
+    }
 }