71 lines
3.2 KiB
PHP
71 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Business;
|
|
|
|
use App\Models\Auth\Permission;
|
|
use Modules\EcommerceFinance\Repositories\CourierFreightReconciliationMirrorRepository;
|
|
use Tests\Feature\FeatureTestCase;
|
|
|
|
class CourierFreightReconciliationPageTest extends FeatureTestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail());
|
|
$repository = \Mockery::mock(CourierFreightReconciliationMirrorRepository::class);
|
|
foreach (['available', 'ready', 'state', 'syncStatus', 'paginate', 'requestSummary'] as $method) {
|
|
$repository->shouldNotReceive($method);
|
|
}
|
|
$this->app->instance(CourierFreightReconciliationMirrorRepository::class, $repository);
|
|
}
|
|
|
|
public function test_page_stays_empty_with_old_filters_and_page_number(): void
|
|
{
|
|
$response = $this->loginAs()->get(route('business.pages.show', [
|
|
'section' => 'courier-payables', 'page' => 'freight-reconciliation',
|
|
'express_no' => 'OLD-WAYBILL', 'month' => '2026-09',
|
|
]) . '&page=2');
|
|
|
|
$response->assertOk()
|
|
->assertSeeText('原数据源已停用')
|
|
->assertSeeText('本页面数据已清空,等待接入正确的运费对账数据源。')
|
|
->assertSee('data-summary-count>0', false)
|
|
->assertSee('data-summary-freight>¥ 0.00', false)
|
|
->assertDontSeeText('OLD-WAYBILL')
|
|
->assertDontSeeText('最近同步')
|
|
->assertDontSeeText('正在计算完整筛选汇总')
|
|
->assertDontSee('data-summary-url', false)
|
|
->assertDontSee('jst_order_express_details', false);
|
|
|
|
$document = new \DOMDocument();
|
|
$previous = libxml_use_internal_errors(true);
|
|
$document->loadHTML('<?xml encoding="UTF-8">' . $response->getContent());
|
|
libxml_clear_errors();
|
|
libxml_use_internal_errors($previous);
|
|
$xpath = new \DOMXPath($document);
|
|
$this->assertCount(23, $xpath->query('//table[contains(@class,"recon-table")]/thead/tr/th'));
|
|
$this->assertCount(1, $xpath->query('//table[contains(@class,"recon-table")]/tbody/tr/td[@colspan="23"]'));
|
|
}
|
|
|
|
public function test_old_summary_endpoint_returns_zero_without_querying_the_disabled_source(): void
|
|
{
|
|
$this->loginAs()->get(route('business.pages.show', [
|
|
'section' => 'courier-payables', 'page' => 'freight-reconciliation',
|
|
'courier_summary' => 1, 'month' => '2026-09', 'express_no' => 'OLD-WAYBILL',
|
|
]))->assertOk()->assertExactJson([
|
|
'data' => ['count' => 0, 'freight' => 0],
|
|
'status' => 'disabled',
|
|
'message' => '原数据源已停用,本页面不再展示原运费对账数据。',
|
|
])->assertHeader('Cache-Control', 'no-store, private');
|
|
}
|
|
|
|
public function test_summary_is_not_available_without_login(): void
|
|
{
|
|
$this->withExceptionHandling()->get(route('business.pages.show', [
|
|
'company_id' => $this->company->id,
|
|
'section' => 'courier-payables', 'page' => 'freight-reconciliation', 'courier_summary' => 1,
|
|
]))->assertRedirect();
|
|
}
|
|
}
|