178 lines
6.6 KiB
PHP
178 lines
6.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Business;
|
|
|
|
use App\Business\TableRegistry;
|
|
use App\Business\UpstreamBusinessInformation;
|
|
use App\Models\Auth\Permission;
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
use Mockery;
|
|
use Tests\Feature\FeatureTestCase;
|
|
|
|
class ManagementCrudTest extends FeatureTestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->user->attachPermission(
|
|
Permission::where('name', 'read-admin-panel')->firstOrFail()
|
|
);
|
|
}
|
|
|
|
public function testCompanyInformationUsesWorkbookHeadersAndReadOnlyUpstreamRows(): void
|
|
{
|
|
$this->mockUpstreamPage((object) [
|
|
'id' => 1045,
|
|
'unified_social_credit_code' => '91320404MADJRTTA0U',
|
|
'company_name' => '测试上游公司',
|
|
'subscribed_capital' => '10.00',
|
|
'company_type' => '店铺-普通公司',
|
|
'establishment_date' => '2024-04-28',
|
|
'legal_representative' => '测试法人',
|
|
'registered_address' => '测试地址',
|
|
'business_scope' => '测试经营范围',
|
|
'basic_deposit_account_number' => 'J0001',
|
|
'company_status' => '正常',
|
|
'financial_officer' => '测试财务',
|
|
'supervisor' => '',
|
|
'taxpayer_category' => '小规模纳税人',
|
|
'shareholders' => null,
|
|
]);
|
|
|
|
$this->loginAs()
|
|
->get(route('business.pages.show', [
|
|
'section' => 'company-management',
|
|
'page' => 'basic-information',
|
|
]))
|
|
->assertOk()
|
|
->assertSeeText('公司信息')
|
|
->assertSeeText('认缴注册资本(万元)')
|
|
->assertSeeText('基本存款账户编号')
|
|
->assertSeeText('纳税类别及类型')
|
|
->assertSeeText('测试上游公司')
|
|
->assertSeeText('工作平台数据库')
|
|
->assertDontSeeText('导入')
|
|
->assertDontSeeText('新增');
|
|
}
|
|
|
|
public function testStoreInformationKeepsTwelveHeadersAndShowsReadOnlyUpstreamRows(): void
|
|
{
|
|
$this->mockUpstreamPage((object) [
|
|
'id' => 2047,
|
|
'opened_at' => '2026-07-18',
|
|
'erp_store_name' => '测试上游店铺',
|
|
'unified_social_credit_code' => '91320412MA216EYU49',
|
|
'company_name' => '测试关联公司',
|
|
'trademark_number' => '35774784',
|
|
'trademark_name' => null,
|
|
'platform' => '天猫',
|
|
'profit_center' => '运营中心A',
|
|
'store_manager' => '测试负责人',
|
|
'store_status' => '正常',
|
|
'store_type' => '旗舰店',
|
|
'channel_mode' => '直销',
|
|
]);
|
|
|
|
$response = $this->loginAs()->get(route('business.pages.show', [
|
|
'section' => 'store-management',
|
|
'page' => 'basic-information',
|
|
]));
|
|
|
|
$response
|
|
->assertOk()
|
|
->assertSeeText('ERP系统店铺名称')
|
|
->assertSeeText('公司社会统一信用码')
|
|
->assertSeeText('渠道模式')
|
|
->assertSeeText('测试上游店铺')
|
|
->assertSeeText('测试关联公司')
|
|
->assertSeeText('工作平台数据库')
|
|
->assertDontSeeText('导入')
|
|
->assertDontSeeText('新增');
|
|
|
|
preg_match_all('/<th(?:\s|>)/', $response->getContent(), $headers);
|
|
$this->assertCount(13, $headers[0]);
|
|
}
|
|
|
|
public function testTrademarkInformationShowsReadOnlyUpstreamRows(): void
|
|
{
|
|
$this->mockUpstreamPage((object) [
|
|
'id' => 600,
|
|
'trademark_name' => '测试上游商标',
|
|
'trademark_type' => '20',
|
|
'trademark_status' => '有效',
|
|
'registration_date' => '2025-12-21',
|
|
'expiry_date' => '2035-12-20',
|
|
'notes' => null,
|
|
]);
|
|
|
|
$this->loginAs()
|
|
->get(route('business.pages.show', [
|
|
'section' => 'trademark-management',
|
|
'page' => 'information',
|
|
]))
|
|
->assertOk()
|
|
->assertSeeText('商标名称')
|
|
->assertSeeText('注册日期')
|
|
->assertSeeText('测试上游商标')
|
|
->assertSeeText('工作平台数据库')
|
|
->assertDontSeeText('导入')
|
|
->assertDontSeeText('新增');
|
|
}
|
|
|
|
public function testTargetManagementSectionsOnlyUseChineseTableHeaders(): void
|
|
{
|
|
$pages = [
|
|
['company-management', 'basic-information'],
|
|
['company-management', 'registration'],
|
|
['company-management', 'changes'],
|
|
['company-management', 'cancellation'],
|
|
['company-management', 'tax-data'],
|
|
['company-management', 'store-data'],
|
|
['trademark-management', 'registration'],
|
|
['trademark-management', 'changes'],
|
|
['trademark-management', 'renewal'],
|
|
['trademark-management', 'information'],
|
|
['store-management', 'basic-information'],
|
|
['store-management', 'opening-process'],
|
|
['store-management', 'changes'],
|
|
['store-management', 'closing-process'],
|
|
['store-management', 'change-log'],
|
|
['fund-management', 'store-receiving-accounts', 'taobao-alipay'],
|
|
['fund-management', 'bank-accounts'],
|
|
['fund-management', 'shared-company-accounts'],
|
|
['fund-management', 'fund-forecast'],
|
|
['financial-sw', 'planning'],
|
|
['financial-sw', 'actual-statistics'],
|
|
];
|
|
|
|
foreach ($pages as $route) {
|
|
[$section, $page] = $route;
|
|
$tab = $route[2] ?? null;
|
|
$descriptor = TableRegistry::describe($section, $page, $tab);
|
|
|
|
$this->assertNotNull($descriptor, "{$section}/{$page} 缺少表格描述配置");
|
|
|
|
if ($page === 'store-receiving-accounts') {
|
|
$this->assertSame('store_platform', $descriptor->tabFilterColumn);
|
|
}
|
|
|
|
foreach ($descriptor->fields as $field) {
|
|
$this->assertMatchesRegularExpression(
|
|
'/\p{Han}/u',
|
|
$field['label'],
|
|
"{$section}/{$page} 的 {$field['name']} 仍在使用英文表头 {$field['label']}"
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
private function mockUpstreamPage(object $row): void
|
|
{
|
|
$paginator = new LengthAwarePaginator([$row], 1, 50, 1, ['path' => '/']);
|
|
$service = Mockery::mock(UpstreamBusinessInformation::class);
|
|
$service->shouldReceive('paginate')->once()->andReturn($paginator);
|
|
$this->app->instance(UpstreamBusinessInformation::class, $service);
|
|
}
|
|
}
|