126 lines
5.1 KiB
PHP
126 lines
5.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Business;
|
|
|
|
use Mockery;
|
|
use Modules\EcommerceFinance\Repositories\PromotionMarketingExpenseRepository;
|
|
use Tests\Feature\FeatureTestCase;
|
|
|
|
class PromotionMarketingAccountBillsTest extends FeatureTestCase
|
|
{
|
|
public function test_promotion_marketing_tab_is_next_to_vipshop_jx(): void
|
|
{
|
|
$pages = collect(config('business_navigation'))
|
|
->firstWhere('slug', 'billing-transactions')['pages'];
|
|
$tabs = collect($pages)->firstWhere('slug', 'store-receiving-bills')['tabs'];
|
|
$slugs = array_column($tabs, 'slug');
|
|
$vipshopJxIndex = array_search('vipshop-jx', $slugs, true);
|
|
|
|
$this->assertNotFalse($vipshopJxIndex);
|
|
$this->assertSame('promotion-marketing', $slugs[$vipshopJxIndex + 1] ?? null);
|
|
$this->assertSame('推广费(营销账户)', $tabs[$vipshopJxIndex + 1]['title'] ?? null);
|
|
|
|
$this->loginAs()
|
|
->get(route('business.pages.show', [
|
|
'section' => 'billing-transactions',
|
|
'page' => 'store-receiving-bills',
|
|
'tab' => 'promotion-marketing',
|
|
]))
|
|
->assertOk()
|
|
->assertSeeText('推广费(营销账户)');
|
|
}
|
|
|
|
public function test_promotion_marketing_page_and_details_share_contract(): void
|
|
{
|
|
$repository = Mockery::mock(PromotionMarketingExpenseRepository::class);
|
|
$result = [
|
|
'rows' => [[
|
|
'id' => 'row-1',
|
|
'store_name' => '测试推广店',
|
|
'occurred_at' => '2026-10-23 09:00:00',
|
|
'notes' => '商品推广',
|
|
'expense' => 12.34,
|
|
]],
|
|
'total' => 1,
|
|
'current_page' => 1,
|
|
'last_page' => 1,
|
|
'per_page' => 20,
|
|
'summary' => ['expense' => 12.34, 'count' => 1],
|
|
'platform_summary' => [['platform' => '淘系', 'amount' => 12.34]],
|
|
];
|
|
$repository->shouldReceive('paginate')->once()->ordered()->with([
|
|
'start' => '',
|
|
'end' => '',
|
|
'store_name' => '',
|
|
'note' => '',
|
|
], 1, 10)->andReturn($result);
|
|
$repository->shouldReceive('storeSummary')->once()->ordered()->with([
|
|
'start' => '2026-10-01',
|
|
'end' => '2026-10-31',
|
|
'store_name' => '',
|
|
'note' => '推广',
|
|
])->andReturn([
|
|
'store_summary' => [[
|
|
'platform' => '淘系',
|
|
'store_name' => '测试推广店',
|
|
'amount' => 12.34,
|
|
]],
|
|
'platform_summary' => [['platform' => '淘系', 'amount' => 12.34]],
|
|
'total' => 12.34,
|
|
]);
|
|
$this->app->instance(PromotionMarketingExpenseRepository::class, $repository);
|
|
|
|
$this->loginAs()
|
|
->getJson(route('ecommerce-finance.account-bills.index', [
|
|
'bill_type' => 'promotion-marketing',
|
|
]))
|
|
->assertOk()
|
|
->assertJsonPath('total', 1)
|
|
->assertJsonPath('summary.expense', 12.34)
|
|
->assertJsonPath('columns.title', '推广费(营销账户)')
|
|
->assertJsonPath('data.0.store_name', '测试推广店')
|
|
->assertJsonPath('columns.columns.0.label', '店铺名称')
|
|
->assertJsonPath('columns.columns.1.label', '交易时间')
|
|
->assertJsonPath('columns.columns.2.label', '备注')
|
|
->assertJsonPath('columns.columns.3.label', '支出金额');
|
|
|
|
$this->loginAs()
|
|
->getJson(route('ecommerce-finance.account-bills.promotion-expense-details', [
|
|
'bill_type' => 'promotion-marketing',
|
|
'start' => '2026-10-01',
|
|
'end' => '2026-10-31',
|
|
'note' => '推广',
|
|
]))
|
|
->assertOk()
|
|
->assertJsonPath('total', 1)
|
|
->assertJsonPath('summary.expense', 12.34)
|
|
->assertJsonPath('summary.count', 1)
|
|
->assertJsonPath('platform_summary.0.platform', '淘系')
|
|
->assertJsonPath('store_summary.0.platform', '淘系')
|
|
->assertJsonPath('store_summary.0.store_name', '测试推广店')
|
|
->assertJsonPath('store_summary.0.amount', 12.34);
|
|
}
|
|
|
|
public function test_promotion_marketing_store_options_come_from_the_same_date_range(): void
|
|
{
|
|
$repository = Mockery::mock(PromotionMarketingExpenseRepository::class);
|
|
$repository->shouldReceive('storeOptions')->once()->with([
|
|
'start' => '2026-10-01',
|
|
'end' => '2026-10-31',
|
|
'store_name' => '',
|
|
'note' => '',
|
|
])->andReturn(['测试推广店', '另一推广店']);
|
|
$this->app->instance(PromotionMarketingExpenseRepository::class, $repository);
|
|
|
|
$this->loginAs()
|
|
->getJson(route('ecommerce-finance.account-bills.filter-options', [
|
|
'bill_type' => 'promotion-marketing',
|
|
'start' => '2026-10-01',
|
|
'end' => '2026-10-31',
|
|
]))
|
|
->assertOk()
|
|
->assertJsonPath('shops.0', '测试推广店')
|
|
->assertJsonPath('shops.1', '另一推广店');
|
|
}
|
|
}
|