Skip to content

Commit 9159d6f

Browse files
committed
ACP2E-782: Introduce an alternative way to define fixtures using PHP8 Attributes
1 parent ab81ebb commit 9159d6f

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

dev/tests/api-functional/framework/Magento/TestFramework/Annotation/ApiDataFixture.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ class ApiDataFixture extends DataFixture
3131
public function startTest(TestCase $test)
3232
{
3333
Bootstrap::getInstance()->reinitialize();
34-
/** Apply method level fixtures if thy are available, apply class level fixtures otherwise */
35-
$this->_applyFixtures(
36-
$this->_getFixtures($test, 'method') ?: $this->_getFixtures($test, 'class'),
37-
$test
38-
);
34+
$this->_applyFixtures($this->_getFixtures($test), $test);
3935
}
4036

4137
/**
@@ -46,8 +42,6 @@ public function startTest(TestCase $test)
4642
public function endTest(TestCase $test)
4743
{
4844
$this->_revertFixtures($test);
49-
$objectManager = Bootstrap::getObjectManager();
50-
$objectManager->get(AttributeMetadataCache::class)->clean();
5145
}
5246

5347
/**
@@ -65,4 +59,23 @@ protected function getDbIsolationState(TestCase $test)
6559
{
6660
return parent::getDbIsolationState($test) ?: ['disabled'];
6761
}
62+
63+
/**
64+
* @inheritdoc
65+
*/
66+
protected function _applyFixtures(array $fixtures, TestCase $test)
67+
{
68+
Bootstrap::getInstance()->reinitialize();
69+
parent::_applyFixtures($fixtures, $test);
70+
}
71+
72+
/**
73+
* @inheritdoc
74+
*/
75+
protected function _revertFixtures(?TestCase $test = null)
76+
{
77+
parent::_revertFixtures($test);
78+
$objectManager = Bootstrap::getObjectManager();
79+
$objectManager->get(AttributeMetadataCache::class)->clean();
80+
}
6881
}

0 commit comments

Comments
 (0)