|
@@ -107,7 +107,10 @@ class MaintenanceTest extends TestCase
|
|
|
$this->assertSame(10, DB::table('maintenance_settings')->count());
|
|
$this->assertSame(10, DB::table('maintenance_settings')->count());
|
|
|
$this->assertSame(0, DB::table('maintenance_settings')->where('enabled', 1)->count());
|
|
$this->assertSame(0, DB::table('maintenance_settings')->where('enabled', 1)->count());
|
|
|
$this->assertSame(ShareDefaults::categories(), Policy::CATEGORIES);
|
|
$this->assertSame(ShareDefaults::categories(), Policy::CATEGORIES);
|
|
|
- $this->assertSame(10 + count(self::GAME_LIST) + count(Policy::SPORTS), $this->service->listing([])['total']);
|
|
|
|
|
|
|
+ $all = $this->service->listing([]);
|
|
|
|
|
+ $this->assertSame(10, $all['total'], 'only site and categories are paged');
|
|
|
|
|
+ $this->assertSame(count(self::GAME_LIST) + count(Policy::SPORTS), array_sum(array_map(fn ($r) => count($r['children']), $all['data'])), 'subcategories are nested');
|
|
|
|
|
+ $this->assertSame([], $all['data'][0]['children'], 'site has no children');
|
|
|
$this->assertSame(0, DB::table('maintenance_settings')->where('enabled', 1)->count());
|
|
$this->assertSame(0, DB::table('maintenance_settings')->where('enabled', 1)->count());
|
|
|
$this->assertNull($this->decide());
|
|
$this->assertNull($this->decide());
|
|
|
$this->assertContains('UTC', $this->service->options()['timezones']);
|
|
$this->assertContains('UTC', $this->service->options()['timezones']);
|
|
@@ -171,6 +174,21 @@ class MaintenanceTest extends TestCase
|
|
|
$edited = $this->service->save(['id' => $row['id'], 'timezone' => 'America/New_York']);
|
|
$edited = $this->service->save(['id' => $row['id'], 'timezone' => 'America/New_York']);
|
|
|
$this->assertSame($row['starts_at_utc'], $edited['starts_at_utc']); $this->assertSame('2026-10-25 21:00:00', $edited['starts_at']);
|
|
$this->assertSame($row['starts_at_utc'], $edited['starts_at_utc']); $this->assertSame('2026-10-25 21:00:00', $edited['starts_at']);
|
|
|
$this->assertSame(1, $this->service->listing(['scope_code' => 'third:2'])['total']);
|
|
$this->assertSame(1, $this->service->listing(['scope_code' => 'third:2'])['total']);
|
|
|
|
|
+ $this->assertSame([], $this->service->listing(['scope_code' => 'third:2'])['data'][0]['children'], 'third:2 has no subcategories in this fixture');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function test_enabled_child_shows_under_its_parent_even_when_parent_is_off(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->service->listing([]); // 子项的维护行在第一次读取列表时补齐
|
|
|
|
|
+ $this->save([], 'self:lottery:pc28');
|
|
|
|
|
+ $list = $this->service->listing(['enabled' => 1]);
|
|
|
|
|
+ $this->assertSame(['self:lottery'], array_column($list['data'], 'scope_code'));
|
|
|
|
|
+ $this->assertFalse($list['data'][0]['matched'], 'parent itself is off');
|
|
|
|
|
+ $this->assertSame(['self:lottery:pc28'], array_column($list['data'][0]['children'], 'scope_code'));
|
|
|
|
|
+ $this->assertSame(count(self::GAME_LIST), $list['data'][0]['children_count'], 'children_count counts all subcategories');
|
|
|
|
|
+ $off = collect($this->service->listing(['enabled' => 0])['data'])->firstWhere('scope_code', 'self:lottery');
|
|
|
|
|
+ $this->assertTrue($off['matched']);
|
|
|
|
|
+ $this->assertNotContains('self:lottery:pc28', array_column($off['children'], 'scope_code'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function test_subcategory_can_be_maintained_without_closing_its_category(): void
|
|
public function test_subcategory_can_be_maintained_without_closing_its_category(): void
|
|
@@ -185,10 +203,13 @@ class MaintenanceTest extends TestCase
|
|
|
['item_type' => 'platform', 'plat_type' => 'bad code', 'game_type' => 2, 'name' => '忽略', 'status' => 1],
|
|
['item_type' => 'platform', 'plat_type' => 'bad code', 'game_type' => 2, 'name' => '忽略', 'status' => 1],
|
|
|
]);
|
|
]);
|
|
|
$list = $this->service->listing(['parent_scope' => 'third:2']);
|
|
$list = $this->service->listing(['parent_scope' => 'third:2']);
|
|
|
- $this->assertSame(['third:2:pg', 'third:2:jdb'], array_column($list['data'], 'scope_code'));
|
|
|
|
|
- $this->assertSame('电子 / PG电子', $list['data'][0]['scope_name']);
|
|
|
|
|
- $this->assertSame('电子 / JDB', $list['data'][1]['scope_name']);
|
|
|
|
|
- $this->assertSame('subcategory', $list['data'][0]['scope_level']);
|
|
|
|
|
|
|
+ $this->assertSame(1, $list['total']);
|
|
|
|
|
+ $this->assertSame(['third:2', 'category', 2], [$list['data'][0]['scope_code'], $list['data'][0]['scope_level'], $list['data'][0]['children_count']]);
|
|
|
|
|
+ $kids = $list['data'][0]['children'];
|
|
|
|
|
+ $this->assertSame(['third:2:pg', 'third:2:jdb'], array_column($kids, 'scope_code'));
|
|
|
|
|
+ $this->assertSame('电子 / PG电子', $kids[0]['scope_name']);
|
|
|
|
|
+ $this->assertSame('电子 / JDB', $kids[1]['scope_name']);
|
|
|
|
|
+ $this->assertSame('subcategory', $kids[0]['scope_level']);
|
|
|
$row = $this->save(['translations' => ['zh' => ['content' => 'PG维护']]], 'third:2:pg');
|
|
$row = $this->save(['translations' => ['zh' => ['content' => 'PG维护']]], 'third:2:pg');
|
|
|
$this->assertSame('third:2', $row['parent_scope']);
|
|
$this->assertSame('third:2', $row['parent_scope']);
|
|
|
$this->assertSame('third:2:pg', $row['subcategory']);
|
|
$this->assertSame('third:2:pg', $row['subcategory']);
|
|
@@ -200,7 +221,9 @@ class MaintenanceTest extends TestCase
|
|
|
$this->save(['platforms' => ['H5']]);
|
|
$this->save(['platforms' => ['H5']]);
|
|
|
$this->assertSame('site', $this->decide('H5', 'third:2', 'third:2:pg')['scope_code']);
|
|
$this->assertSame('site', $this->decide('H5', 'third:2', 'third:2:pg')['scope_code']);
|
|
|
$this->assertSame('third:2:pg', $this->decide('PC', 'third:2', 'third:2:pg')['scope_code']);
|
|
$this->assertSame('third:2:pg', $this->decide('PC', 'third:2', 'third:2:pg')['scope_code']);
|
|
|
- $lottery = $this->service->listing(['scope_code' => 'self:lottery:pc28'])['data'][0];
|
|
|
|
|
|
|
+ $parent = $this->service->listing(['scope_code' => 'self:lottery:pc28'])['data'][0];
|
|
|
|
|
+ $this->assertSame(['self:lottery', false], [$parent['scope_code'], $parent['matched']], 'searching a child returns its parent as container');
|
|
|
|
|
+ $lottery = $parent['children'][0];
|
|
|
$this->assertSame('F1彩票 / 加拿大28', $lottery['scope_name']);
|
|
$this->assertSame('F1彩票 / 加拿大28', $lottery['scope_name']);
|
|
|
$this->assertSame('self:lottery', $lottery['parent_scope']);
|
|
$this->assertSame('self:lottery', $lottery['parent_scope']);
|
|
|
$this->assertSame('site', $this->service->detail($this->id())['scope_level']);
|
|
$this->assertSame('site', $this->service->detail($this->id())['scope_level']);
|
|
@@ -208,9 +231,9 @@ class MaintenanceTest extends TestCase
|
|
|
$this->assertContains(['value' => 'third:2:pg', 'label' => '电子 / PG电子', 'parent' => 'third:2'], $this->service->options()['subcategories']);
|
|
$this->assertContains(['value' => 'third:2:pg', 'label' => '电子 / PG电子', 'parent' => 'third:2'], $this->service->options()['subcategories']);
|
|
|
$this->assertSame(['self:lottery:pc28', 'self:lottery:jisu28', 'self:lottery:lhc:3', 'self:lottery:lhc:1', 'self:lottery:lhc:4',
|
|
$this->assertSame(['self:lottery:pc28', 'self:lottery:jisu28', 'self:lottery:lhc:3', 'self:lottery:lhc:1', 'self:lottery:lhc:4',
|
|
|
'self:lottery:lhc:2', 'self:lottery:jisu:1', 'self:lottery:jisu:2', 'self:lottery:jisu:3', 'self:lottery:jisu:6',
|
|
'self:lottery:lhc:2', 'self:lottery:jisu:1', 'self:lottery:jisu:2', 'self:lottery:jisu:3', 'self:lottery:jisu:6',
|
|
|
- 'self:lottery:jisu:4', 'self:lottery:jisu:5', 'self:lottery:jisu:7'], array_column($this->service->listing(['parent_scope' => 'self:lottery'])['data'], 'scope_code'));
|
|
|
|
|
- $this->assertSame('F1彩票 / 新澳门六合彩', $this->service->listing(['scope_code' => 'self:lottery:lhc:1'])['data'][0]['scope_name']);
|
|
|
|
|
- $sports = $this->service->listing(['parent_scope' => 'self:sport'])['data'];
|
|
|
|
|
|
|
+ 'self:lottery:jisu:4', 'self:lottery:jisu:5', 'self:lottery:jisu:7'], array_column($this->service->listing(['parent_scope' => 'self:lottery'])['data'][0]['children'], 'scope_code'));
|
|
|
|
|
+ $this->assertSame('F1彩票 / 新澳门六合彩', $this->service->listing(['scope_code' => 'self:lottery:lhc:1'])['data'][0]['children'][0]['scope_name']);
|
|
|
|
|
+ $sports = $this->service->listing(['parent_scope' => 'self:sport'])['data'][0]['children'];
|
|
|
$this->assertSame(['足球', '篮球', '乒乓球', '排球', '板球', '网球'], array_map(fn ($r) => explode(' / ', $r['scope_name'])[1], $sports));
|
|
$this->assertSame(['足球', '篮球', '乒乓球', '排球', '板球', '网球'], array_map(fn ($r) => explode(' / ', $r['scope_name'])[1], $sports));
|
|
|
$this->save([], 'self:sport:basketball');
|
|
$this->save([], 'self:sport:basketball');
|
|
|
$this->assertSame('self:sport:basketball', $this->decide('PC', 'self:sport', 'self:sport:basketball')['scope_code']);
|
|
$this->assertSame('self:sport:basketball', $this->decide('PC', 'self:sport', 'self:sport:basketball')['scope_code']);
|
|
@@ -258,7 +281,7 @@ class MaintenanceTest extends TestCase
|
|
|
$this->assertFalse(DB::table('maintenance_translations')->where('maintenance_id', $child['id'])->exists());
|
|
$this->assertFalse(DB::table('maintenance_translations')->where('maintenance_id', $child['id'])->exists());
|
|
|
|
|
|
|
|
$migration->up();
|
|
$migration->up();
|
|
|
- $this->assertSame(0, $this->service->listing(['scope_code' => 'self:lottery:pc28'])['data'][0]['enabled']);
|
|
|
|
|
|
|
+ $this->assertSame(0, $this->service->listing(['scope_code' => 'self:lottery:pc28'])['data'][0]['children'][0]['enabled']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#[DataProvider('invalidInputs')]
|
|
#[DataProvider('invalidInputs')]
|