63 lines
2.4 KiB
PHP
63 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\EcommerceFinance;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
use Modules\EcommerceFinance\Repositories\DingProcessDetailMirrorRepository;
|
|
use Modules\EcommerceFinance\View\ProcessDetailsPageData;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ProcessDetailsPageDataTest extends TestCase
|
|
{
|
|
public function test_page_data_contains_real_paginator_filters_and_summary(): void
|
|
{
|
|
$row = (object) [
|
|
'business_id' => '202610241052000241951',
|
|
'line_no' => 1,
|
|
'status' => '审批中',
|
|
];
|
|
|
|
$repository = $this->createMock(DingProcessDetailMirrorRepository::class);
|
|
$repository->expects($this->once())
|
|
->method('paginate')
|
|
->with($this->callback(static fn (array $filters): bool => $filters['month'] === '2026-10'), 2, 50)
|
|
->willReturn([
|
|
'data' => [$row],
|
|
'total' => 11331,
|
|
'summary' => [
|
|
'rows' => 11331,
|
|
'approvals' => 4775,
|
|
'amount_total' => 225953332.98,
|
|
'bank_amount_total' => 225862410.66,
|
|
],
|
|
'status' => 'succeeded',
|
|
'last_synced_at' => '2026-10-26 16:55:11',
|
|
'scope' => 'personal_permission',
|
|
]);
|
|
$repository->expects($this->once())
|
|
->method('filterOptions')
|
|
->willReturn([
|
|
'months' => ['2026-10'],
|
|
'document_types' => ['种菜核销/种菜报销'],
|
|
'statuses' => ['审批中'],
|
|
]);
|
|
|
|
$data = (new ProcessDetailsPageData($repository))->page(Request::create(
|
|
'/1/workspace/financial-operations/process-details',
|
|
'GET',
|
|
['month' => '2026-10', 'page' => 2],
|
|
));
|
|
|
|
$this->assertInstanceOf(LengthAwarePaginator::class, $data['processRows']);
|
|
$this->assertSame(11331, $data['processRows']->total());
|
|
$this->assertSame(50, $data['processRows']->perPage());
|
|
$this->assertSame(2, $data['processRows']->currentPage());
|
|
$this->assertSame($row, $data['processRows']->items()[0]);
|
|
$this->assertSame('succeeded', $data['mirrorStatus']);
|
|
$this->assertSame(11331, $data['summary']['rows']);
|
|
$this->assertSame(['2026-10'], $data['months']);
|
|
$this->assertNull($data['error']);
|
|
}
|
|
}
|