Skip to content

Commit 13dae24

Browse files
committed
Testing: Fixed issues during pre-release testing
- Updated locale list - Fixed new name sorting not being case insensitive - Updated license test to account for changed deps
1 parent 6211d6b commit 13dae24

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

app/Sorting/SortSetOperationComparisons.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class SortSetOperationComparisons
1313
{
1414
public static function nameAsc(Entity $a, Entity $b): int
1515
{
16-
return $a->name <=> $b->name;
16+
return strtolower($a->name) <=> strtolower($b->name);
1717
}
1818

1919
public static function nameDesc(Entity $a, Entity $b): int
2020
{
21-
return $b->name <=> $a->name;
21+
return strtolower($b->name) <=> strtolower($a->name);
2222
}
2323

2424
public static function nameNumericAsc(Entity $a, Entity $b): int

app/Translation/LocaleManager.php

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class LocaleManager
4747
'ja' => 'ja',
4848
'ka' => 'ka_GE',
4949
'ko' => 'ko_KR',
50+
'ku' => 'ku_TR',
5051
'lt' => 'lt_LT',
5152
'lv' => 'lv_LV',
5253
'nb' => 'nb_NO',

tests/Meta/LicensesTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function test_licenses_endpoint()
1313
$resp->assertSee('Licenses');
1414
$resp->assertSee('PHP Library Licenses');
1515
$resp->assertSee('Dan Brown and the BookStack project contributors');
16-
$resp->assertSee('doctrine/dbal');
16+
$resp->assertSee('league/commonmark');
1717
$resp->assertSee('@codemirror/lang-html');
1818
}
1919

tests/Sorting/SortRuleTest.php

+34
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,40 @@ public function test_auto_book_sort_does_not_touch_timestamps()
187187
$this->assertNotEquals($oldPriority, $chapter->priority);
188188
}
189189

190+
public function test_name_alphabetical_ordering()
191+
{
192+
$book = Book::factory()->create();
193+
$rule = SortRule::factory()->create(['sequence' => 'name_asc']);
194+
$book->sort_rule_id = $rule->id;
195+
$book->save();
196+
$this->permissions->regenerateForEntity($book);
197+
198+
$namesToAdd = [
199+
"Beans",
200+
"bread",
201+
"Milk",
202+
"pizza",
203+
"Tomato",
204+
];
205+
206+
$reverseNamesToAdd = array_reverse($namesToAdd);
207+
foreach ($reverseNamesToAdd as $name) {
208+
$this->actingAsApiEditor()->post("/api/pages", [
209+
'book_id' => $book->id,
210+
'name' => $name,
211+
'markdown' => 'Hello'
212+
]);
213+
}
214+
215+
foreach ($namesToAdd as $index => $name) {
216+
$this->assertDatabaseHas('pages', [
217+
'book_id' => $book->id,
218+
'name' => $name,
219+
'priority' => $index + 1,
220+
]);
221+
}
222+
}
223+
190224
public function test_name_numeric_ordering()
191225
{
192226
$book = Book::factory()->create();

0 commit comments

Comments
 (0)