6 declare(strict_types=1);
19 use PHPUnit\Framework\TestCase;
27 private $cacheTypeList;
30 private $configReader;
33 private $modeSwitcher;
36 private $objectManager;
42 private $isDimensionMode =
false;
47 private function restoreDb()
51 $this->db->restoreFromDbDump();
52 $this->cacheTypeList = $this->objectManager->get(TypeListInterface::class);
53 $this->cacheTypeList->cleanType(
'config');
54 $this->objectManager->get(Config::class)->clean();
62 private function setDimensionMode(
string $mode, TestCase $test)
65 $this->modeSwitcher = $this->objectManager->get(ModeSwitcher::class);
66 $this->configReader = $this->objectManager->get(ScopeConfigInterface::class);
67 $this->cacheTypeList = $this->objectManager->get(TypeListInterface::class);
69 $this->configReader->clean();
73 if ($previousMode !==
$mode) {
75 $this->modeSwitcher->switchMode(
$mode, $previousMode);
76 $this->objectManager->get(Config::class)->clean();
78 $this->fail(
'Dimensions mode for indexer has not been changed', $test);
91 $source = $test->getAnnotations();
93 if (isset(
$source[
'method'][
'magentoIndexerDimensionMode'])) {
94 $annotations =
$source[
'method'][
'magentoIndexerDimensionMode'];
95 }
elseif (isset(
$source[
'class'][
'magentoIndexerDimensionMode'])) {
96 $annotations =
$source[
'class'][
'magentoIndexerDimensionMode'];
101 $dbIsolation =
$source[
'method'][
'magentoDbIsolation']
102 ??
$source[
'class'][
'magentoDbIsolation']
105 if ($dbIsolation[0] !=
'disabled') {
106 $this->fail(
"Invalid @magentoDbIsolation declaration: $dbIsolation[0]", $test);
109 list($indexerType, $indexerMode) = explode(
' ', $annotations[0]);
112 $this->isDimensionMode =
true;
113 $this->setDimensionMode($indexerMode, $test);
124 if ($this->isDimensionMode) {
126 $this->isDimensionMode =
false;
137 private function fail(
$message, TestCase $test)
139 $test->fail(
"{$message} in the test '{$test->toString()}'");
elseif(isset( $params[ 'redirect_parent']))
const XML_PATH_PRICE_DIMENSIONS_MODE
startTest(TestCase $test)
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
static getObjectManager()