Add new chat effects and shop items
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:商店控制器功能测试
|
||||
* 覆盖商品列表、购买、改名卡与新增特效商品展示等商店流程。
|
||||
*/
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\ShopItem;
|
||||
@@ -8,10 +13,17 @@ use App\Models\UserPurchase;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* 商店控制器功能测试
|
||||
* 验证商店接口对商品与购买逻辑的返回结果。
|
||||
*/
|
||||
class ShopControllerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* 测试商品列表接口只返回上架商品。
|
||||
*/
|
||||
public function test_items_returns_active_shop_items()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
@@ -41,6 +53,33 @@ class ShopControllerTest extends TestCase
|
||||
$this->assertFalse($responseItems->contains('id', $inactiveItem->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试商店商品列表会包含新增的特效单次卡与周卡。
|
||||
*/
|
||||
public function test_items_include_new_effect_shop_cards(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->getJson(route('shop.items'));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertJsonFragment(['slug' => 'once_meteors']);
|
||||
$response->assertJsonFragment(['slug' => 'once_gold-rain']);
|
||||
$response->assertJsonFragment(['slug' => 'once_hearts']);
|
||||
$response->assertJsonFragment(['slug' => 'once_confetti']);
|
||||
$response->assertJsonFragment(['slug' => 'once_fireflies']);
|
||||
$response->assertJsonFragment(['slug' => 'once_sakura']);
|
||||
$response->assertJsonFragment(['slug' => 'week_sakura']);
|
||||
$response->assertJsonFragment(['slug' => 'week_meteors']);
|
||||
$response->assertJsonFragment(['slug' => 'week_gold-rain']);
|
||||
$response->assertJsonFragment(['slug' => 'week_hearts']);
|
||||
$response->assertJsonFragment(['slug' => 'week_confetti']);
|
||||
$response->assertJsonFragment(['slug' => 'week_fireflies']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试一次性道具可以正常购买。
|
||||
*/
|
||||
public function test_can_buy_one_time_item()
|
||||
{
|
||||
$user = User::factory()->create(['jjb' => 500]);
|
||||
@@ -73,6 +112,9 @@ class ShopControllerTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试余额不足时不能购买商品。
|
||||
*/
|
||||
public function test_cannot_buy_if_insufficient_funds()
|
||||
{
|
||||
$user = User::factory()->create(['jjb' => 50]);
|
||||
@@ -99,6 +141,9 @@ class ShopControllerTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试已下架商品不能购买。
|
||||
*/
|
||||
public function test_cannot_buy_inactive_item()
|
||||
{
|
||||
$user = User::factory()->create(['jjb' => 500]);
|
||||
@@ -122,6 +167,9 @@ class ShopControllerTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试改名卡可以被正常使用。
|
||||
*/
|
||||
public function test_can_use_rename_card()
|
||||
{
|
||||
$user = User::factory()->create(['username' => 'OldName']);
|
||||
|
||||
Reference in New Issue
Block a user