allowPage(); $repository = Mockery::mock(StoreReceivingDewuAlipayBillMirrorRepository::class); $repository->shouldReceive('paginate') ->once() ->with( Mockery::on(static fn (array $filters): bool => ($filters['start'] ?? null) === '2026-10-01' && ($filters['end'] ?? null) === '2026-10-31'), 'occurred_at', 'desc', 1, 20, ) ->andReturn([ 'data' => [[ 'record_code' => '2000000001360000001', 'store_name' => '支付宝-常州阔之煜家居有限公司', 'bill_item' => '商家代付货款', 'alipay_account' => '2088841085257651', 'occurred_at' => '2026-10-27 18:52:15', 'income' => 21815.89, 'expense' => 0, 'balance' => 92957.40, ]], 'total' => 1, 'current_page' => 1, 'last_page' => 1, 'per_page' => 20, 'summary' => [ 'income' => 21815.89, 'expense' => 0, 'opening_balance' => 71141.51, 'opening_balance_date' => '2026-09-30', 'opening_balance_source' => 'previous_period', 'balance' => 92957.40, 'count' => 1, ], 'sync' => ['status' => 'succeeded', 'last_succeeded_at' => '2026-11-01 09:00:00'], ]); $this->app->instance(StoreReceivingDewuAlipayBillMirrorRepository::class, $repository); $response = $this->loginAs() ->getJson(route('ecommerce-finance.account-bills.index', [ 'bill_type' => 'dewu-alipay', 'start' => '2026-10-01', 'end' => '2026-10-31', 'limit' => 20, ])) ->assertOk() ->assertJsonPath('columns.title', '得物支付宝账户') ->assertJsonPath('total', 1) ->assertJsonPath('data.0.alipay_account', '2088841085257651') ->assertJsonPath('summary.balance', 92957.4); $columnLabels = array_column($response->json('columns.columns'), 'label'); $actualStoreIndex = array_search('线上单号对应实际店铺', $columnLabels, true); $this->assertSame( ['支付宝账户名', '得物店铺', '商户号'], array_slice($columnLabels, $actualStoreIndex + 1, 3), ); } public function test_filter_options_expose_the_eight_scoped_accounts(): void { $this->allowPage(); $repository = Mockery::mock(StoreReceivingDewuAlipayBillMirrorRepository::class); $repository->shouldReceive('filterOptions')->once()->andReturn([ 'shops' => StoreReceivingDewuAlipayBillMirrorRepository::STORE_NAMES, 'bill_items' => ['商家代付货款', '技术服务费'], ]); $this->app->instance(StoreReceivingDewuAlipayBillMirrorRepository::class, $repository); $response = $this->loginAs() ->getJson(route('ecommerce-finance.account-bills.filter-options', [ 'bill_type' => 'dewu-alipay', ])) ->assertOk() ->assertJsonPath('bill_items.1', '技术服务费') ->assertJsonCount(8, 'shops'); $this->assertContains( '支付宝-常州春之华家居有限公司', $response->json('shops'), ); } private function allowPage(): void { $this->user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail(), ); } }