CaiWuXiTong/tests/Unit/View/ThirdPartyWarehouseStorageViewTest.php

107 lines
4.3 KiB
PHP

<?php
namespace Tests\Unit\View;
use PHPUnit\Framework\TestCase;
class ThirdPartyWarehouseStorageViewTest extends TestCase
{
public function test_view_keeps_the_excel_columns_in_the_required_order(): void
{
$source = $this->viewSource();
preg_match_all(
"/\\['key' => '([^']+)', 'label' => '([^']+)'(?:, 'type' => '[^']+')?\\],/",
$source,
$matches,
PREG_SET_ORDER
);
$columns = array_map(
static fn (array $match): array => [$match[1], $match[2]],
array_slice($matches, 0, 45)
);
$this->assertSame([
['owner', '货主'],
['sku_code', '商品编码'],
['image_url', '图片'],
['product_name', '商品名称'],
['short_name', '商品简称'],
['supplier', '供应商'],
['category', '分类'],
['virtual_category', '虚拟分类'],
['supplier_style_no', '供应商款号'],
['color_spec', '颜色规格'],
['brand', '品牌'],
['unit', '单位'],
['opening_qty', '期初数量'],
['closing_qty', '期末数量'],
['processing_in', '加工进仓'],
['processing_out', '加工出仓'],
['purchase_in', '采购进仓'],
['purchase_return', '采购退货'],
['other_in', '其它进仓'],
['other_return', '其它退货'],
['sales_out', '销售出仓'],
['sales_return', '销售退货'],
['stocktake', '盘点'],
['transfer_out', '调拨出'],
['transfer_in', '调拨入'],
['opening_aux', '期初'],
['other_out', '其它出库'],
['turnover_days', '库存周转天数'],
['opening_amount', '期初金额'],
['closing_amount', '期末金额'],
['price_type', '价格类型'],
['order_type', '叫货类型'],
['other_price_3', '其它价格3'],
['other_price_4', '其它价格4'],
['package_count', '包件数'],
['model_spec', '规格型号'],
['board_type', '板材类型'],
['purchase_type', '采购类型'],
['other_attribute_4', '其它属性4'],
['production_status', '生产状态'],
['other_attribute_6', '其它属性6'],
['item_no', '货号'],
['single_double_package', '单双包'],
['drawing_id', '图纸ID'],
['material', '材质'],
], $columns);
}
public function test_view_reuses_finance_table_preferences_and_has_explicit_sync_states(): void
{
$source = $this->viewSource();
$this->assertStringContainsString('data-finance-table-surface', $source);
$this->assertStringContainsString('data-finance-field-picker', $source);
$this->assertStringContainsString('data-finance-table', $source);
$this->assertStringContainsString('data-finance-export-base', $source);
$this->assertStringContainsString('data-finance-export-query', $source);
$this->assertStringContainsString('name="dimension" value="month"', $source);
$this->assertStringContainsString('name="dimension" value="day"', $source);
$this->assertStringContainsString('name="period"', $source);
$this->assertStringContainsString("\$rows->appends(\$activeFilters)", $source);
$this->assertStringContainsString('data-warehouse-period', $source);
$this->assertStringContainsString('每日 03:20 自动同步', $source);
$this->assertStringContainsString('首次同步尚未完成', $source);
$this->assertStringContainsString('当前展示最近一次成功同步的数据', $source);
$this->assertStringContainsString("in_array(\$scheme, ['http', 'https'], true)", $source);
$this->assertStringContainsString('referrerpolicy="no-referrer"', $source);
}
private function viewSource(): string
{
$root = dirname(__DIR__, 3);
$source = file_get_contents(
$root . '/resources/views/business/pages/courier-payables/third-party-warehouse-storage.blade.php'
);
$this->assertIsString($source);
return $source;
}
}