Skip to content

Commit d1c3567

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

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\TestFramework\Annotation;
99

1010
use Magento\Customer\Model\Metadata\AttributeMetadataCache;
11+
use Magento\TestFramework\Event\Param\Transaction;
1112
use Magento\TestFramework\Helper\Bootstrap;
1213
use PHPUnit\Framework\TestCase;
1314

@@ -37,6 +38,8 @@ public function startTest(TestCase $test)
3738
public function endTest(TestCase $test)
3839
{
3940
$this->_revertFixtures($test);
41+
$objectManager = Bootstrap::getObjectManager();
42+
$objectManager->get(AttributeMetadataCache::class)->clean();
4043
}
4144

4245
/**
@@ -58,18 +61,18 @@ protected function getDbIsolationState(TestCase $test)
5861
/**
5962
* @inheritdoc
6063
*/
61-
protected function _applyFixtures(array $fixtures, TestCase $test)
64+
public function startTestTransactionRequest(TestCase $test, Transaction $param): void
6265
{
6366
Bootstrap::getInstance()->reinitialize();
64-
parent::_applyFixtures($fixtures, $test);
67+
parent::startTestTransactionRequest($test, $param);
6568
}
6669

6770
/**
6871
* @inheritdoc
6972
*/
70-
protected function _revertFixtures(?TestCase $test = null)
73+
public function endTestTransactionRequest(TestCase $test, Transaction $param): void
7174
{
72-
parent::_revertFixtures($test);
75+
parent::endTestTransactionRequest($test, $param);
7376
$objectManager = Bootstrap::getObjectManager();
7477
$objectManager->get(AttributeMetadataCache::class)->clean();
7578
}

dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/ProductTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public function testGetAttributeRawValue()
7676
* @throws StateException
7777
*/
7878
#[
79-
AttributeFixture(['attribute_code' => 'prod_attr']),
80-
ProductFixture(['sku' => 'simple']),
79+
DataFixture(AttributeFixture::class, ['attribute_code' => 'prod_attr']),
80+
DataFixture(ProductFixture::class, ['sku' => 'simple']),
8181
]
8282
public function testGetAttributeRawValueGetDefault()
8383
{

0 commit comments

Comments
 (0)