diff --git a/app/Sorting/SortSetOperationComparisons.php b/app/Sorting/SortSetOperationComparisons.php index 0d8e582648e..e3465231573 100644 --- a/app/Sorting/SortSetOperationComparisons.php +++ b/app/Sorting/SortSetOperationComparisons.php @@ -13,12 +13,12 @@ class SortSetOperationComparisons { public static function nameAsc(Entity $a, Entity $b): int { - return $a->name <=> $b->name; + return strtolower($a->name) <=> strtolower($b->name); } public static function nameDesc(Entity $a, Entity $b): int { - return $b->name <=> $a->name; + return strtolower($b->name) <=> strtolower($a->name); } public static function nameNumericAsc(Entity $a, Entity $b): int diff --git a/app/Translation/LocaleManager.php b/app/Translation/LocaleManager.php index 0e2e7372ff6..86e712beec9 100644 --- a/app/Translation/LocaleManager.php +++ b/app/Translation/LocaleManager.php @@ -47,6 +47,7 @@ class LocaleManager 'ja' => 'ja', 'ka' => 'ka_GE', 'ko' => 'ko_KR', + 'ku' => 'ku_TR', 'lt' => 'lt_LT', 'lv' => 'lv_LV', 'nb' => 'nb_NO', diff --git a/tests/Meta/LicensesTest.php b/tests/Meta/LicensesTest.php index 0d6af2555cf..a50fbdb9095 100644 --- a/tests/Meta/LicensesTest.php +++ b/tests/Meta/LicensesTest.php @@ -13,7 +13,7 @@ public function test_licenses_endpoint() $resp->assertSee('Licenses'); $resp->assertSee('PHP Library Licenses'); $resp->assertSee('Dan Brown and the BookStack project contributors'); - $resp->assertSee('doctrine/dbal'); + $resp->assertSee('league/commonmark'); $resp->assertSee('@codemirror/lang-html'); } diff --git a/tests/Sorting/SortRuleTest.php b/tests/Sorting/SortRuleTest.php index 85b3d7991c4..e956f49df4b 100644 --- a/tests/Sorting/SortRuleTest.php +++ b/tests/Sorting/SortRuleTest.php @@ -187,6 +187,40 @@ public function test_auto_book_sort_does_not_touch_timestamps() $this->assertNotEquals($oldPriority, $chapter->priority); } + public function test_name_alphabetical_ordering() + { + $book = Book::factory()->create(); + $rule = SortRule::factory()->create(['sequence' => 'name_asc']); + $book->sort_rule_id = $rule->id; + $book->save(); + $this->permissions->regenerateForEntity($book); + + $namesToAdd = [ + "Beans", + "bread", + "Milk", + "pizza", + "Tomato", + ]; + + $reverseNamesToAdd = array_reverse($namesToAdd); + foreach ($reverseNamesToAdd as $name) { + $this->actingAsApiEditor()->post("/api/pages", [ + 'book_id' => $book->id, + 'name' => $name, + 'markdown' => 'Hello' + ]); + } + + foreach ($namesToAdd as $index => $name) { + $this->assertDatabaseHas('pages', [ + 'book_id' => $book->id, + 'name' => $name, + 'priority' => $index + 1, + ]); + } + } + public function test_name_numeric_ordering() { $book = Book::factory()->create();