diff --git a/CHANGELOG.md b/CHANGELOG.md index b34030e..6365a3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- Support for new overrides feature introduced in Magento 2.4.0 / 2.4.1 ## [1.1.0] diff --git a/framework/ReachDigital/TestFramework/Bootstrap/DocBlock.php b/framework/ReachDigital/TestFramework/Bootstrap/DocBlock.php index 6b9660b..caa0109 100644 --- a/framework/ReachDigital/TestFramework/Bootstrap/DocBlock.php +++ b/framework/ReachDigital/TestFramework/Bootstrap/DocBlock.php @@ -11,12 +11,19 @@ class DocBlock extends \Magento\TestFramework\Bootstrap\DocBlock protected function _getSubscribers(\Magento\TestFramework\Application $application) { - return [ + $subscribers = [ new \Magento\TestFramework\Workaround\Segfault(), // new \Magento\TestFramework\Workaround\Cleanup\TestCaseProperties(), // new \Magento\TestFramework\Workaround\Cleanup\StaticProperties(), new \Magento\TestFramework\Isolation\WorkingDirectory(), new \Magento\TestFramework\Isolation\DeploymentConfig(), + ]; + + if (class_exists(\Magento\TestFramework\Workaround\Override\Fixture\Resolver\TestSetter::class)) { + $subscribers[] = new \Magento\TestFramework\Workaround\Override\Fixture\Resolver\TestSetter(); + } + + $subscribers = array_merge($subscribers, [ new \ReachDigital\TestFramework\Annotation\AppIsolation($application), new \Magento\TestFramework\Annotation\IndexerDimensionMode($application), new \Magento\TestFramework\Isolation\AppConfig(), @@ -35,6 +42,8 @@ protected function _getSubscribers(\Magento\TestFramework\Application $applicati new \Magento\TestFramework\Annotation\Cache($application), new \Magento\TestFramework\Annotation\AdminConfigFixture(), new \Magento\TestFramework\Annotation\ConfigFixture(), - ]; + ]); + + return $subscribers; } } diff --git a/framework/bootstrap.php b/framework/bootstrap.php index 95b5bd8..0fb2f2a 100644 --- a/framework/bootstrap.php +++ b/framework/bootstrap.php @@ -133,8 +133,22 @@ new Magento\Framework\App\Utility\Files(new ComponentRegistrar(), $dirSearch, $themePackageList) ); + if (class_exists(\Magento\TestFramework\Workaround\Override\Config::class)) { + /** @var \Magento\TestFramework\Workaround\Override\Config $overrideConfig */ + $overrideConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + Magento\TestFramework\Workaround\Override\Config::class + ); + $overrideConfig->init(); + Magento\TestFramework\Workaround\Override\Config::setInstance($overrideConfig); + Magento\TestFramework\Workaround\Override\Fixture\Resolver::setInstance( + new \Magento\TestFramework\Workaround\Override\Fixture\Resolver($overrideConfig) + ); + } else { + $overrideConfig = null; + } + /* Unset declared global variables to release the PHPUnit from maintaining their values between tests */ - unset($testsBaseDir, $logWriter, $settings, $shell, $application, $bootstrap); + unset($testsBaseDir, $logWriter, $settings, $shell, $application, $bootstrap, $overrideConfig); } catch (Exception $e) { // phpcs:ignore Magento2.Security.LanguageConstruct.DirectOutput echo $e . PHP_EOL; diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 30b72cd..300e7e0 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -56,6 +56,7 @@ +