mirror of
https://gitee.com/ShopeX/ECShopX
synced 2026-08-04 19:26:23 +08:00
4.6.4
This commit is contained in:
@@ -43,4 +43,106 @@ final class StoreHomePageServiceInternalNameTest extends TestCase
|
||||
$this->assertFalse(StoreHomePageService::pageTemplateDetailHasNonEmptyList(['list' => []]));
|
||||
$this->assertTrue(StoreHomePageService::pageTemplateDetailHasNonEmptyList(['list' => [['x' => 1]]]));
|
||||
}
|
||||
|
||||
public function testCustomDecorationSettingVersionCandidatesForShopIncludesV101Fallback(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
['shop_12', 'v1.0.1'],
|
||||
StoreHomePageService::customDecorationSettingVersionCandidates(12, 0)
|
||||
);
|
||||
}
|
||||
|
||||
public function testCustomDecorationSettingVersionCandidatesForHeadquarters(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
['v1.0.1'],
|
||||
StoreHomePageService::customDecorationSettingVersionCandidates(0, 0)
|
||||
);
|
||||
}
|
||||
|
||||
public function testDecorationTemplateNameCandidatesFallsBackToYykweishop(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
['my_theme', 'yykweishop'],
|
||||
StoreHomePageService::decorationTemplateNameCandidates(['template_name' => 'my_theme'])
|
||||
);
|
||||
}
|
||||
|
||||
public function testPagesTemplateListSearchPlansForShop(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
[
|
||||
['distributor_id' => 8, 'weapp_pages' => 'distributor_index'],
|
||||
['distributor_id' => 8, 'weapp_pages' => 'index'],
|
||||
['distributor_id' => 0, 'weapp_pages' => 'index'],
|
||||
],
|
||||
StoreHomePageService::pagesTemplateListSearchPlans(8)
|
||||
);
|
||||
}
|
||||
|
||||
public function testBuildPageTemplateDetailFromTemplateConfList(): void
|
||||
{
|
||||
$detail = StoreHomePageService::buildPageTemplateDetailFromTemplateConfList([
|
||||
['name' => 'slider', 'params' => ['name' => 'slider', 'base' => [], 'data' => []]],
|
||||
['name' => 'plain', 'params' => ['title' => 'x']],
|
||||
]);
|
||||
$this->assertCount(1, $detail['config']);
|
||||
$this->assertCount(2, $detail['list']);
|
||||
}
|
||||
|
||||
public function testSafeDecodeWeappSettingParamsSupportsSerializeAndJson(): void
|
||||
{
|
||||
$payload = ['name' => 'page', 'base' => []];
|
||||
$this->assertSame($payload, StoreHomePageService::safeDecodeWeappSettingParams(serialize($payload)));
|
||||
$this->assertSame($payload, StoreHomePageService::safeDecodeWeappSettingParams(json_encode($payload)));
|
||||
}
|
||||
|
||||
public function testBuildTemplateConfListFromWeappSettingEntities(): void
|
||||
{
|
||||
$payload = ['name' => 'page', 'base' => []];
|
||||
$entity = new class($payload) {
|
||||
private $params;
|
||||
|
||||
public function __construct(array $params)
|
||||
{
|
||||
$this->params = serialize($params);
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return 53453;
|
||||
}
|
||||
|
||||
public function getTemplateName()
|
||||
{
|
||||
return 'yykweishop';
|
||||
}
|
||||
|
||||
public function getCompanyId()
|
||||
{
|
||||
return 34;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'page';
|
||||
}
|
||||
|
||||
public function getPageName()
|
||||
{
|
||||
return 'custom_106';
|
||||
}
|
||||
|
||||
public function getParams()
|
||||
{
|
||||
return $this->params;
|
||||
}
|
||||
};
|
||||
|
||||
$list = StoreHomePageService::buildTemplateConfListFromWeappSettingEntities([$entity], 34, 'yykweishop');
|
||||
$this->assertCount(1, $list);
|
||||
$this->assertSame('page', $list[0]['name']);
|
||||
$this->assertSame($payload, $list[0]['params']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user