![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/dev/tests/integration/framework/Magento/TestFramework/Annotation/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\TestFramework\Annotation; use Magento\TestFramework\Event\Param\Transaction; use Magento\TestFramework\Fixture\Parser\DataFixtureAttributesParser; use Magento\TestFramework\Helper\Bootstrap; use PHPUnit\Framework\TestCase; /** * Implementation of the @magentoDataFixture DocBlock annotation. */ class DataFixture extends AbstractDataFixture { public const ANNOTATION = 'magentoDataFixture'; /** * Handler for 'startTestTransactionRequest' event * * @param TestCase $test * @param Transaction $param * @return void */ public function startTestTransactionRequest(TestCase $test, Transaction $param): void { $fixtures = $this->_getFixtures($test); /* Start transaction before applying first fixture to be able to revert them all further */ if ($fixtures) { if ($this->getDbIsolationState($test) !== ['disabled']) { $param->requestTransactionStart(); } else { $this->_applyFixtures($fixtures, $test); } } } /** * Handler for 'endTestNeedTransactionRollback' event * * @param TestCase $test * @param Transaction $param * @return void */ public function endTestTransactionRequest(TestCase $test, Transaction $param): void { /* Isolate other tests from test-specific fixtures */ if ($this->_appliedFixtures && $this->_getFixtures($test)) { if ($this->getDbIsolationState($test) !== ['disabled']) { $param->requestTransactionRollback(); } else { $this->_revertFixtures($test); } } } /** * Handler for 'startTransaction' event * * @param TestCase $test * @return void */ public function startTransaction(TestCase $test): void { $this->_applyFixtures($this->_getFixtures($test), $test); } /** * Handler for 'rollbackTransaction' event * * @param TestCase $test * @return void */ public function rollbackTransaction(): void { $this->_revertFixtures(); } /** * @inheritdoc */ protected function getAnnotation(): string { return self::ANNOTATION; } /** * @inheritdoc */ protected function getParsers(): array { $parsers = []; $parsers[] = Bootstrap::getObjectManager()->get( \Magento\TestFramework\Fixture\Parser\DataFixture::class ); return array_merge( parent::getParsers(), $parsers ); } }