/**
  * @test
  * @dataProvider isMethods
  */
 public function contextMethodsReturnTheCorrectValues($contextName, $isDevelopment, $isProduction, $isTesting, $parentContext)
 {
     $context = new ApplicationContext($contextName);
     $this->assertSame($isDevelopment, $context->isDevelopment());
     $this->assertSame($isProduction, $context->isProduction());
     $this->assertSame($isTesting, $context->isTesting());
     $this->assertSame((string) $parentContext, (string) $context->getParent());
 }
 /**
  * Loads special configuration defined in the specified packages and merges them with
  * those potentially existing in the global configuration folders. The result is stored
  * in the configuration manager's configuration registry and can be retrieved with the
  * getConfiguration() method.
  *
  * @param string $configurationType The kind of configuration to load - must be one of the CONFIGURATION_TYPE_* constants
  * @param array $packages An array of Package objects (indexed by package key) to consider
  * @throws Exception\InvalidConfigurationTypeException
  * @throws Exception\InvalidConfigurationException
  * @return void
  */
 protected function loadConfiguration($configurationType, array $packages)
 {
     $this->cacheNeedsUpdate = true;
     $configurationProcessingType = $this->resolveConfigurationProcessingType($configurationType);
     $allowSplitSource = $this->isSplitSourceAllowedForConfigurationType($configurationType);
     switch ($configurationProcessingType) {
         case self::CONFIGURATION_PROCESSING_TYPE_SETTINGS:
             // Make sure that the Flow package is the first item of the packages array:
             if (isset($packages['TYPO3.Flow'])) {
                 $flowPackage = $packages['TYPO3.Flow'];
                 unset($packages['TYPO3.Flow']);
                 $packages = array_merge(array('TYPO3.Flow' => $flowPackage), $packages);
                 unset($flowPackage);
             }
             $settings = array();
             /** @var $package PackageInterface */
             foreach ($packages as $packageKey => $package) {
                 if (Arrays::getValueByPath($settings, $packageKey) === null) {
                     $settings = Arrays::setValueByPath($settings, $packageKey, array());
                 }
                 $settings = Arrays::arrayMergeRecursiveOverrule($settings, $this->configurationSource->load($package->getConfigurationPath() . $configurationType, $allowSplitSource));
             }
             $settings = Arrays::arrayMergeRecursiveOverrule($settings, $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $configurationType, $allowSplitSource));
             foreach ($this->orderedListOfContextNames as $contextName) {
                 /** @var $package PackageInterface */
                 foreach ($packages as $package) {
                     $settings = Arrays::arrayMergeRecursiveOverrule($settings, $this->configurationSource->load($package->getConfigurationPath() . $contextName . '/' . $configurationType, $allowSplitSource));
                 }
                 $settings = Arrays::arrayMergeRecursiveOverrule($settings, $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $contextName . '/' . $configurationType, $allowSplitSource));
             }
             if ($this->configurations[$configurationType] !== array()) {
                 $this->configurations[$configurationType] = Arrays::arrayMergeRecursiveOverrule($this->configurations[$configurationType], $settings);
             } else {
                 $this->configurations[$configurationType] = $settings;
             }
             $this->configurations[$configurationType]['TYPO3']['Flow']['core']['context'] = (string) $this->context;
             break;
         case self::CONFIGURATION_PROCESSING_TYPE_OBJECTS:
             $this->configurations[$configurationType] = array();
             /** @var $package PackageInterface */
             foreach ($packages as $packageKey => $package) {
                 $configuration = $this->configurationSource->load($package->getConfigurationPath() . $configurationType);
                 $configuration = Arrays::arrayMergeRecursiveOverrule($configuration, $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $configurationType));
                 foreach ($this->orderedListOfContextNames as $contextName) {
                     $configuration = Arrays::arrayMergeRecursiveOverrule($configuration, $this->configurationSource->load($package->getConfigurationPath() . $contextName . '/' . $configurationType));
                     $configuration = Arrays::arrayMergeRecursiveOverrule($configuration, $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $contextName . '/' . $configurationType));
                 }
                 $this->configurations[$configurationType][$packageKey] = $configuration;
             }
             break;
         case self::CONFIGURATION_PROCESSING_TYPE_POLICY:
             if ($this->context->isTesting()) {
                 $testingPolicyPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'Policy';
                 if ($this->configurationSource->has($testingPolicyPathAndFilename)) {
                     $this->configurations[$configurationType] = $this->configurationSource->load($testingPolicyPathAndFilename);
                     break;
                 }
             }
             $this->configurations[$configurationType] = array();
             /** @var $package PackageInterface */
             foreach ($packages as $package) {
                 $packagePolicyConfiguration = $this->configurationSource->load($package->getConfigurationPath() . $configurationType, $allowSplitSource);
                 $this->validatePolicyConfiguration($packagePolicyConfiguration, $package);
                 $this->configurations[$configurationType] = $this->mergePolicyConfiguration($this->configurations[$configurationType], $packagePolicyConfiguration);
             }
             $this->configurations[$configurationType] = $this->mergePolicyConfiguration($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $configurationType, $allowSplitSource));
             foreach ($this->orderedListOfContextNames as $contextName) {
                 /** @var $package PackageInterface */
                 foreach ($packages as $package) {
                     $packagePolicyConfiguration = $this->configurationSource->load($package->getConfigurationPath() . $contextName . '/' . $configurationType, $allowSplitSource);
                     $this->validatePolicyConfiguration($packagePolicyConfiguration, $package);
                     $this->configurations[$configurationType] = $this->mergePolicyConfiguration($this->configurations[$configurationType], $packagePolicyConfiguration);
                 }
                 $this->configurations[$configurationType] = $this->mergePolicyConfiguration($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $contextName . '/' . $configurationType, $allowSplitSource));
             }
             break;
         case self::CONFIGURATION_PROCESSING_TYPE_DEFAULT:
             $this->configurations[$configurationType] = array();
             /** @var $package PackageInterface */
             foreach ($packages as $package) {
                 $this->configurations[$configurationType] = Arrays::arrayMergeRecursiveOverrule($this->configurations[$configurationType], $this->configurationSource->load($package->getConfigurationPath() . $configurationType, $allowSplitSource));
             }
             $this->configurations[$configurationType] = Arrays::arrayMergeRecursiveOverrule($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $configurationType, $allowSplitSource));
             foreach ($this->orderedListOfContextNames as $contextName) {
                 /** @var $package PackageInterface */
                 foreach ($packages as $package) {
                     $this->configurations[$configurationType] = Arrays::arrayMergeRecursiveOverrule($this->configurations[$configurationType], $this->configurationSource->load($package->getConfigurationPath() . $contextName . '/' . $configurationType, $allowSplitSource));
                 }
                 $this->configurations[$configurationType] = Arrays::arrayMergeRecursiveOverrule($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $contextName . '/' . $configurationType, $allowSplitSource));
             }
             break;
         case self::CONFIGURATION_PROCESSING_TYPE_ROUTES:
             // load main routes
             $this->configurations[$configurationType] = array();
             foreach (array_reverse($this->orderedListOfContextNames) as $contextName) {
                 $this->configurations[$configurationType] = array_merge($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $contextName . '/' . $configurationType));
             }
             $this->configurations[$configurationType] = array_merge($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $configurationType));
             // Merge routes with SubRoutes recursively
             $this->mergeRoutesWithSubRoutes($this->configurations[$configurationType]);
             break;
         case self::CONFIGURATION_PROCESSING_TYPE_APPEND:
             $this->configurations[$configurationType] = array();
             /** @var $package PackageInterface */
             foreach ($packages as $package) {
                 $this->configurations[$configurationType] = array_merge($this->configurations[$configurationType], $this->configurationSource->load($package->getConfigurationPath() . $configurationType, $allowSplitSource));
             }
             $this->configurations[$configurationType] = array_merge($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $configurationType, $allowSplitSource));
             foreach ($this->orderedListOfContextNames as $contextName) {
                 foreach ($packages as $package) {
                     $this->configurations[$configurationType] = array_merge($this->configurations[$configurationType], $this->configurationSource->load($package->getConfigurationPath() . $contextName . '/' . $configurationType, $allowSplitSource));
                 }
                 $this->configurations[$configurationType] = array_merge($this->configurations[$configurationType], $this->configurationSource->load(FLOW_PATH_CONFIGURATION . $contextName . '/' . $configurationType, $allowSplitSource));
             }
             break;
         default:
             throw new Exception\InvalidConfigurationTypeException('Configuration type "' . $configurationType . '" cannot be loaded with loadConfiguration().', 1251450613);
     }
     $this->postProcessConfiguration($this->configurations[$configurationType]);
 }