CaiWuXiTong/tests/Feature/Banking/AccountsTest.php
15061959991 1adf627c0d feat: 财务系统二次开发 - 营销账户账单功能
- 基础环境:Docker 部署配置,源码挂载实时同步
- 修复:super_admin 权限补全、登录重定向循环
- 开发:店铺营销账户账单 - 抖音账户(15字段汇总账单)
- 开发:店铺营销账户账单 - 淘系支付宝账户(8字段流水账单)
- 开发:店铺营销账户账单 - 拼多多账户(7字段流水账单)
- 业务页面导航集成:config/business_navigation.php + Business\Pages 控制器
- 各平台独立表结构和视图,互不影响
2026-07-21 18:43:52 +08:00

143 lines
3.8 KiB
PHP

<?php
namespace Tests\Feature\Banking;
use App\Jobs\Banking\CreateAccount;
use App\Models\Banking\Account;
use Tests\Feature\FeatureTestCase;
class AccountsTest extends FeatureTestCase
{
public function testItShouldSeeAccountListPage()
{
$this->loginAs()
->get(route('accounts.index'))
->assertStatus(200)
->assertSeeText(trans_choice('general.accounts', 2));
}
public function testItShouldSeeAccountCreatePage()
{
$this->loginAs()
->get(route('accounts.create'))
->assertStatus(200)
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.accounts', 1)]));
}
public function testItShouldCreateAccount()
{
$request = $this->getRequest();
$this->loginAs()
->post(route('accounts.store'), $request)
->assertStatus(200);
$this->assertFlashLevel('success');
$this->assertDatabaseHas('accounts', $request);
}
public function testItShouldSeeAccountUpdatePage()
{
$request = $this->getRequest();
$account = $this->dispatch(new CreateAccount($request));
$this->loginAs()
->get(route('accounts.edit', $account->id))
->assertStatus(200)
->assertSee($account->name);
}
public function testItShouldUpdateAccount()
{
$request = $this->getRequest();
$account = $this->dispatch(new CreateAccount($request));
$request['name'] = $this->faker->text(10);
$this->loginAs()
->patch(route('accounts.update', $account->id), $request)
->assertStatus(200)
->assertSee($request['name']);
$this->assertFlashLevel('success');
$this->assertDatabaseHas('accounts', $request);
}
public function testItShouldDeleteAccount()
{
$request = $this->getRequest();
$account = $this->dispatch(new CreateAccount($request));
$this->loginAs()
->delete(route('accounts.destroy', $account->id))
->assertStatus(200);
$this->assertFlashLevel('success');
$this->assertSoftDeleted('accounts', $request);
}
public function testItShouldShowAccount()
{
$request = $this->getRequest();
$account = $this->dispatch(new CreateAccount($request));
$this->loginAs()
->get(route('accounts.show', $account->id))
->assertStatus(200)
->assertSee($account->name);
}
public function testItShouldReturnMinimalCurrencyPayloadForAccount()
{
$request = $this->getRequest();
$account = $this->dispatch(new CreateAccount($request));
$response = $this->loginAs()
->get(route('accounts.currency', ['account_id' => $account->id]))
->assertStatus(200)
->assertJsonStructure([
'id',
'currency_name',
'currency_code',
'currency_rate',
'thousands_separator',
'decimal_mark',
'precision',
'symbol_first',
'symbol',
]);
$response->assertJsonMissingPath('balance');
$response->assertJsonMissingPath('title');
$response->assertJsonMissingPath('initials');
$this->assertSame(
[
'id',
'currency_name',
'currency_code',
'currency_rate',
'thousands_separator',
'decimal_mark',
'precision',
'symbol_first',
'symbol',
],
array_keys($response->json())
);
}
public function getRequest()
{
return Account::factory()->enabled()->raw();
}
}