Neos\Flow\Tests\FunctionalTestCase::tearDown PHP Method

tearDown() public method

Note: tearDown() is also called if an exception occurred in one of the tests. If the problem is caused by some security or persistence related part of Flow, the error might be hard to track because their specialized tearDown() methods might cause fatal errors. In those cases just output the original exception message by adding an echo($this->statusMessage) as the first line of this method.
public tearDown ( ) : void
return void
    public function tearDown()
    {
        $this->tearDownSecurity();
        $persistenceManager = self::$bootstrap->getObjectManager()->get(\Neos\Flow\Persistence\PersistenceManagerInterface::class);
        // Explicitly call persistAll() so that the "allObjectsPersisted" signal is sent even if persistAll()
        // has not been called during a test. This makes sure that for example certain repositories can clear
        // their internal registry in order to avoid side effects in the following test run.
        // Wrap in try/catch to suppress errors after the actual test is run (e.g. validation)
        try {
            $persistenceManager->persistAll();
        } catch (\Exception $exception) {
        }
        if (is_callable(array($persistenceManager, 'tearDown'))) {
            $persistenceManager->tearDown();
        }
        self::$bootstrap->getObjectManager()->forgetInstance(\Neos\Flow\Http\Client\InternalRequestEngine::class);
        self::$bootstrap->getObjectManager()->forgetInstance(\Neos\Flow\Persistence\Aspect\PersistenceMagicAspect::class);
        $this->inject(self::$bootstrap->getObjectManager()->get(\Neos\Flow\ResourceManagement\ResourceRepository::class), 'addedResources', new \SplObjectStorage());
        $this->inject(self::$bootstrap->getObjectManager()->get(\Neos\Flow\ResourceManagement\ResourceRepository::class), 'removedResources', new \SplObjectStorage());
        $this->inject(self::$bootstrap->getObjectManager()->get(\Neos\Flow\ResourceManagement\ResourceTypeConverter::class), 'convertedResources', array());
        $this->cleanupPersistentResourcesDirectory();
        $this->emitFunctionalTestTearDown();
    }

Usage Example

 public function tearDown()
 {
     $persistenceManager = self::$bootstrap->getObjectManager()->get(PersistenceManagerInterface::class);
     if (is_callable(array($persistenceManager, 'tearDown'))) {
         $persistenceManager->tearDown();
     }
     self::$bootstrap->getObjectManager()->forgetInstance(PersistenceManagerInterface::class);
     parent::tearDown();
 }
All Usage Examples Of Neos\Flow\Tests\FunctionalTestCase::tearDown