directoryList = $directoryList; $objectManager->configure($this->_primaryConfigData); $objectManager->addSharedInstance($this->directoryList, \Magento\Framework\App\Filesystem\DirectoryList::class); $objectManager->addSharedInstance($this->directoryList, \Magento\Framework\Filesystem\DirectoryList::class); $deploymentConfig = $this->createDeploymentConfig($directoryList, $this->configFilePool, $arguments); $this->factory->setArguments($arguments); $objectManager->addSharedInstance($deploymentConfig, \Magento\Framework\App\DeploymentConfig::class); $objectManager->addSharedInstance( $objectManager->get(\Magento\Framework\App\ObjectManager\ConfigLoader::class), \Magento\Framework\ObjectManager\ConfigLoaderInterface::class ); $objectManager->get(\Magento\Framework\Interception\PluginListInterface::class)->reset(); $objectManager->configure( $objectManager->get(\Magento\Framework\App\ObjectManager\ConfigLoader::class)->load('global') ); return $objectManager; } /** * Load primary config * * @param \Magento\Framework\App\Filesystem\DirectoryList $directoryList * @param DriverPool $driverPool * @param mixed $argumentMapper * @param string $appMode * @return array */ protected function _loadPrimaryConfig(DirectoryList $directoryList, $driverPool, $argumentMapper, $appMode) { if (null === $this->_primaryConfigData) { $this->_primaryConfigData = array_replace( parent::_loadPrimaryConfig($directoryList, $driverPool, $argumentMapper, $appMode), [ 'default_setup' => ['type' => \Magento\TestFramework\Db\ConnectionAdapter::class] ] ); $diPreferences = []; $diPreferencesPath = __DIR__ . '/../../../etc/di/preferences/'; $preferenceFiles = glob($diPreferencesPath . '*.php'); foreach ($preferenceFiles as $file) { if (!is_readable($file)) { throw new LocalizedException(__("'%1' is not readable file.", $file)); } $diPreferences = array_replace($diPreferences, include $file); } $this->_primaryConfigData['preferences'] = array_replace( $this->_primaryConfigData['preferences'], $diPreferences ); } return $this->_primaryConfigData; } }