/** * Clear InstanceManager cache * * @return \Magento\TestFramework\ObjectManager */ public function clearCache() { foreach ($this->_classesToDestruct as $className) { if (isset($this->_sharedInstances[$className])) { $this->_sharedInstances[$className] = null; } } \Magento\Framework\App\Config\Base::destroy(); $sharedInstances = ['Magento\\Framework\\ObjectManagerInterface' => $this, 'Magento\\Framework\\App\\ObjectManager' => $this]; foreach ($this->persistedInstances as $persistedClass) { if (isset($this->_sharedInstances[$persistedClass])) { $sharedInstances[$persistedClass] = $this->_sharedInstances[$persistedClass]; } } $this->_sharedInstances = $sharedInstances; $this->_config->clean(); return $this; }