Files
ECShopX/tests/OperatorCartFastBuyCoexistenceStructureTest.php
wanghai 058673559c 4.7.0
2026-06-26 19:20:24 +08:00

54 lines
2.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* store-ops-buy-now-cloud-stock共存与回归结构断言
* TC-COEX-01、TC-COEX-02、TC-REG-01
*
* 通过方法体隔离性保证:立即购买不写 OperatorCart普通加车不碰店务立即购买 Redis 分桶。
*/
use CompanysBundle\Services\OperatorCartService;
class OperatorCartFastBuyCoexistenceStructureTest extends TestCase
{
private function methodBody(string $class, string $method): string
{
$ref = new ReflectionMethod($class, $method);
$file = $ref->getFileName();
$this->assertNotFalse($file);
$lines = file($file, FILE_IGNORE_NEW_LINES);
$this->assertIsArray($lines);
$slice = array_slice($lines, $ref->getStartLine() - 1, $ref->getEndLine() - $ref->getStartLine() + 1);
return implode("\n", $slice);
}
/**
* TC-COEX-01 / S16立即购买路径不持久化到 OperatorCart 表(与普通行互不影响的一侧保证)。
*/
public function testTcCoex01FastBuyDoesNotUseEntityRepository(): void
{
$body = $this->methodBody(OperatorCartService::class, 'addFastBuyCartdata');
$this->assertStringNotContainsString('entityRepository', $body);
}
/**
* TC-COEX-02 / S17普通 cartDataAdd 不读写店务立即购买 Redis 分桶。
*/
public function testTcCoex02CartDataAddDoesNotTouchShopFastBuyRedis(): void
{
$body = $this->methodBody(OperatorCartService::class, 'addCartdata');
$this->assertStringNotContainsString('OperatorShopFastBuyRedisService', $body);
$this->assertStringNotContainsString('shop_fastbuy', $body);
}
/**
* TC-REG-01 / S15普通加车仍走 _checkAddCartItems门店 store 校验保留在重构后路径上)。
*/
public function testTcReg01AddCartdataStillUsesCheckAddCartItems(): void
{
$body = $this->methodBody(OperatorCartService::class, 'addCartdata');
$this->assertStringContainsString('_checkAddCartItems', $body);
}
}