优化游戏通知
This commit is contained in:
@@ -27,6 +27,9 @@ class BaccaratControllerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* 方法功能:初始化百家乐默认配置。
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -46,7 +49,10 @@ class BaccaratControllerTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_can_get_current_round()
|
||||
/**
|
||||
* 方法功能:验证可以获取当前百家乐局次。
|
||||
*/
|
||||
public function test_can_get_current_round(): void
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = User::factory()->create(['jjb' => 3456]);
|
||||
@@ -73,7 +79,10 @@ class BaccaratControllerTest extends TestCase
|
||||
$this->assertSame(3456, $response->json('jjb'));
|
||||
}
|
||||
|
||||
public function test_can_bet()
|
||||
/**
|
||||
* 方法功能:验证可以下注并给房间在线用户广播右下角通知。
|
||||
*/
|
||||
public function test_can_bet(): void
|
||||
{
|
||||
Event::fake();
|
||||
|
||||
@@ -112,9 +121,24 @@ class BaccaratControllerTest extends TestCase
|
||||
]);
|
||||
|
||||
Event::assertDispatched(\App\Events\BaccaratPoolUpdated::class);
|
||||
|
||||
$messages = Redis::lrange('room:1:messages', 0, -1);
|
||||
$publicMessage = collect($messages)
|
||||
->map(fn (string $item) => json_decode($item, true))
|
||||
->first(fn (array $item) => ($item['to_user'] ?? null) === '大家'
|
||||
&& ($item['toast_notification']['title'] ?? null) === '🎲 有人下注百家乐'
|
||||
&& str_contains((string) ($item['toast_notification']['message'] ?? ''), $user->username));
|
||||
|
||||
$this->assertNotNull($publicMessage);
|
||||
$this->assertFalse((bool) ($publicMessage['is_secret'] ?? true));
|
||||
$this->assertStringContainsString($user->username, (string) ($publicMessage['toast_notification']['message'] ?? ''));
|
||||
$this->assertSame('🎲', $publicMessage['toast_notification']['icon'] ?? null);
|
||||
}
|
||||
|
||||
public function test_cannot_bet_out_of_range()
|
||||
/**
|
||||
* 方法功能:验证超出配置范围的下注会被拦截。
|
||||
*/
|
||||
public function test_cannot_bet_out_of_range(): void
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = User::factory()->create(['jjb' => 200]);
|
||||
@@ -143,7 +167,10 @@ class BaccaratControllerTest extends TestCase
|
||||
$response->assertJson(['ok' => false]);
|
||||
}
|
||||
|
||||
public function test_cannot_bet_twice_in_same_round()
|
||||
/**
|
||||
* 方法功能:验证同一用户同一局不能重复下注。
|
||||
*/
|
||||
public function test_cannot_bet_twice_in_same_round(): void
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = User::factory()->create(['jjb' => 200]);
|
||||
@@ -180,7 +207,10 @@ class BaccaratControllerTest extends TestCase
|
||||
$response->assertJson(['ok' => false]);
|
||||
}
|
||||
|
||||
public function test_can_get_history()
|
||||
/**
|
||||
* 方法功能:验证可以获取最近已结算百家乐历史。
|
||||
*/
|
||||
public function test_can_get_history(): void
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = User::factory()->create();
|
||||
|
||||
Reference in New Issue
Block a user