Skip to content

Commit 3c5e6af

Browse files
committed
ACP2E-782: Introduce an alternative way to define fixtures using PHP8 Attributes
1 parent 450d42d commit 3c5e6af

File tree

4 files changed

+12
-46
lines changed

4 files changed

+12
-46
lines changed

dev/tests/integration/framework/Magento/TestFramework/Annotation/AbstractDataFixture.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ protected function getParsers(): array
270270
protected function getDbIsolationState(TestCase $test)
271271
{
272272
$isEnabled = Bootstrap::getObjectManager()->get(DbIsolationState::class)->isEnabled($test);
273-
return $isEnabled === null ? null : [$isEnabled];
273+
return $isEnabled === null ? null : [$isEnabled ? 'enabled' : 'disabled'];
274274
}
275275

276276
/**

dev/tests/integration/framework/Magento/TestFramework/Annotation/IndexerDimensionMode.php

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,15 @@ public function startTest(TestCase $test)
114114

115115
$dbIsolation = Bootstrap::getObjectManager()->get(DbIsolationState::class)->isEnabled($test);
116116

117-
if ($dbIsolation) {
118-
$this->fail("@magentoDbIsolation must be disabled when using @magentoIndexerDimensionMode", $test);
119-
}
120-
121-
if ($values && $values[0]['indexer'] === Processor::INDEXER_ID) {
122-
$this->isDimensionMode = true;
123-
$this->setDimensionMode($values[0]['dimension'], $test);
117+
if ($values) {
118+
if ($dbIsolation) {
119+
$this->fail("@magentoDbIsolation must be disabled when using @magentoIndexerDimensionMode", $test);
120+
}
121+
122+
if ($values[0]['indexer'] === Processor::INDEXER_ID) {
123+
$this->isDimensionMode = true;
124+
$this->setDimensionMode($values[0]['dimension'], $test);
125+
}
124126
}
125127
}
126128

@@ -148,40 +150,4 @@ private function fail($message, TestCase $test)
148150
{
149151
$test->fail("{$message} in the test '{$test->toString()}'");
150152
}
151-
152-
/**
153-
* Returns fixtures defined using IndexerDimensionMode annotation
154-
*
155-
* @param TestCase $test
156-
* @param string $scope
157-
* @return array
158-
* @throws \Exception
159-
*/
160-
private function getFixturesFromAnnotation(TestCase $test, string $scope): array
161-
{
162-
$annotations = TestCaseAnnotation::getInstance()->getAnnotations($test);
163-
$configs = [];
164-
165-
foreach ($annotations[$scope][self::ANNOTATION] ?? [] as $annotation) {
166-
$parts = explode(' ', $annotation);
167-
$configs[] = ['indexer' => $parts[0], 'dimension' => $parts[1]];
168-
}
169-
170-
return $configs;
171-
}
172-
173-
/**
174-
* Returns fixtures defined using IndexerDimensionMode attribute
175-
*
176-
* @param TestCase $test
177-
* @param string $scope
178-
* @return array
179-
* @throws LocalizedException
180-
*/
181-
private function getFixturesFromAttribute(TestCase $test, string $scope): array
182-
{
183-
return Bootstrap::getObjectManager()
184-
->create(\Magento\TestFramework\Fixture\Parser\IndexerDimensionMode::class)
185-
->parse($test, $scope);
186-
}
187153
}

dev/tests/integration/framework/Magento/TestFramework/Annotation/Parser/AppIsolation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function parse(TestCase $test, string $scope): array
3333
__('Invalid "@%1" annotation, can be "enabled" or "disabled" only.', self::ANNOTATION)
3434
);
3535
}
36-
$values[] = ['state' => $value === 'enabled'];
36+
$values[] = ['enabled' => $value === 'enabled'];
3737
}
3838

3939
return $values;

dev/tests/integration/framework/Magento/TestFramework/Annotation/Parser/DbIsolation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function parse(TestCase $test, string $scope): array
3333
__('Invalid "@%1" annotation, can be "enabled" or "disabled" only.', self::ANNOTATION)
3434
);
3535
}
36-
$values[] = ['state' => $value === 'enabled'];
36+
$values[] = ['enabled' => $value === 'enabled'];
3737
}
3838

3939
return $values;

0 commit comments

Comments
 (0)