/**
     * @test
     */
    public function saveConfigurationCacheSavesTheCurrentConfigurationAsPhpCode()
    {
        vfsStream::setup('Flow');
        mkdir(vfsStream::url('Flow/Configuration'));
        $temporaryDirectoryPath = vfsStream::url('Flow/TemporaryDirectory') . '/';
        $includeCachedConfigurationsPathAndFilename = vfsStream::url('Flow/Configuration/IncludeCachedConfigurations.php');
        $mockConfigurations = array(ConfigurationManager::CONFIGURATION_TYPE_ROUTES => array('routes'), ConfigurationManager::CONFIGURATION_TYPE_CACHES => array('caches'), ConfigurationManager::CONFIGURATION_TYPE_SETTINGS => array('settings' => array('foo' => 'bar')));
        $mockEnvironment = $this->getMock('TYPO3\\Flow\\Utility\\Environment', array('getPathToTemporaryDirectory'), array(), '', FALSE);
        $mockEnvironment->expects($this->once())->method('getPathToTemporaryDirectory')->will($this->returnValue($temporaryDirectoryPath));
        $configurationManager = $this->getAccessibleMock('TYPO3\\Flow\\Configuration\\ConfigurationManager', array('postProcessConfiguration'), array(), '', FALSE);
        $configurationManager->injectEnvironment($mockEnvironment);
        $configurationManager->_set('includeCachedConfigurationsPathAndFilename', $includeCachedConfigurationsPathAndFilename);
        $this->mockContext->expects($this->any())->method('__toString')->will($this->returnValue('FooContext'));
        $configurationManager->_set('context', $this->mockContext);
        $configurationManager->_set('configurations', $mockConfigurations);
        $configurationManager->_call('saveConfigurationCache');
        $expectedInclusionCode = <<<EOD
<?php
if (FLOW_PATH_ROOT !== 'XXX' || !file_exists('vfs://Flow/TemporaryDirectory/Configuration/FooContextConfigurations.php')) {
\tunlink(__FILE__);
\treturn array();
}
return require 'vfs://Flow/TemporaryDirectory/Configuration/FooContextConfigurations.php';
EOD;
        $expectedInclusionCode = str_replace('XXX', FLOW_PATH_ROOT, $expectedInclusionCode);
        $this->assertTrue(file_exists($temporaryDirectoryPath . 'Configuration'));
        $this->assertStringEqualsFile($includeCachedConfigurationsPathAndFilename, $expectedInclusionCode);
        $this->assertFileExists($temporaryDirectoryPath . 'Configuration/FooContextConfigurations.php');
        $this->assertSame($mockConfigurations, require $temporaryDirectoryPath . 'Configuration/FooContextConfigurations.php');
    }
    /**
     * @test
     */
    public function saveConfigurationCacheSavesTheCurrentConfigurationAsPhpCode()
    {
        vfsStream::setup('Flow');
        mkdir(vfsStream::url('Flow/Configuration'));
        $temporaryDirectoryPath = vfsStream::url('Flow/TemporaryDirectory') . '/';
        $includeCachedConfigurationsPathAndFilename = vfsStream::url('Flow/Configuration/IncludeCachedConfigurations.php');
        $mockConfigurations = array(ConfigurationManager::CONFIGURATION_TYPE_ROUTES => array('routes'), ConfigurationManager::CONFIGURATION_TYPE_CACHES => array('caches'), ConfigurationManager::CONFIGURATION_TYPE_SETTINGS => array('settings' => array('foo' => 'bar')));
        $configurationManager = $this->getAccessibleMock(\TYPO3\Flow\Configuration\ConfigurationManager::class, array('postProcessConfiguration'), array(), '', false);
        $configurationManager->setTemporaryDirectoryPath($temporaryDirectoryPath);
        $configurationManager->_set('includeCachedConfigurationsPathAndFilename', $includeCachedConfigurationsPathAndFilename);
        $this->mockContext->expects($this->any())->method('__toString')->will($this->returnValue('FooContext'));
        $configurationManager->_set('context', $this->mockContext);
        $configurationManager->_set('configurations', $mockConfigurations);
        $configurationManager->_set('configurationTypes', [ConfigurationManager::CONFIGURATION_TYPE_ROUTES => array('processingType' => ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_ROUTES, 'allowSplitSource' => false), ConfigurationManager::CONFIGURATION_TYPE_CACHES => array('processingType' => ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_DEFAULT, 'allowSplitSource' => false), ConfigurationManager::CONFIGURATION_TYPE_SETTINGS => array('processingType' => ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_DEFAULT, 'allowSplitSource' => false)]);
        $configurationManager->_call('saveConfigurationCache');
        $expectedInclusionCode = <<<EOD
<?php
if (FLOW_PATH_ROOT !== 'XXX' || !file_exists('vfs://Flow/TemporaryDirectory/Configuration/FooContextConfigurations.php')) {
\t@unlink(__FILE__);
\treturn array();
}
return require 'vfs://Flow/TemporaryDirectory/Configuration/FooContextConfigurations.php';
EOD;
        $expectedInclusionCode = str_replace('XXX', FLOW_PATH_ROOT, $expectedInclusionCode);
        $this->assertTrue(file_exists($temporaryDirectoryPath . 'Configuration'));
        $this->assertStringEqualsFile($includeCachedConfigurationsPathAndFilename, $expectedInclusionCode);
        $this->assertFileExists($temporaryDirectoryPath . 'Configuration/FooContextConfigurations.php');
        $this->assertSame($mockConfigurations, require $temporaryDirectoryPath . 'Configuration/FooContextConfigurations.php');
    }
 /**
  * @test
  */
 public function unfreezePackageEmitsPackageStatesUpdatedSignal()
 {
     $this->mockApplicationContext->expects($this->atLeastOnce())->method('isDevelopment')->will($this->returnValue(true));
     $this->packageManager->createPackage('Some.Package', null, null, null, ['name' => 'some/package', 'type' => 'typo3-flow-package']);
     $this->packageManager->freezePackage('Some.Package');
     $this->mockDispatcher->expects($this->once())->method('dispatch')->with(PackageManager::class, 'packageStatesUpdated');
     $this->packageManager->unfreezePackage('Some.Package');
 }
 /**
  * @test
  */
 public function initializeFlushesCachesInDevelopmentContextIfRoutingSettingsWhereNotStoredPreviously()
 {
     $this->mockApplicationContext->expects($this->atLeastOnce())->method('isDevelopment')->will($this->returnValue(true));
     $this->mockRouteCache->expects($this->atLeastOnce())->method('get')->with('routingSettings')->will($this->returnValue(false));
     $this->mockRouteCache->expects($this->once())->method('flush');
     $this->mockResolveCache->expects($this->once())->method('flush');
     $this->routerCachingService->_call('initializeObject');
 }
 /**
  * @test
  */
 public function unfreezePackageEmitsPackageStatesUpdatedSignal()
 {
     $this->mockApplicationContext->expects($this->atLeastOnce())->method('isDevelopment')->will($this->returnValue(TRUE));
     $this->packageManager->createPackage('Some.Package');
     $this->packageManager->freezePackage('Some.Package');
     $this->mockDispatcher->expects($this->once())->method('dispatch')->with('TYPO3\\Flow\\Package\\PackageManager', 'packageStatesUpdated');
     $this->packageManager->unfreezePackage('Some.Package');
 }