/** * @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()); }
/** * Tries to load the reflection data from the compile time cache. * * The compile time cache is only supported for Development context and thus * this function will return in any other context. * * If no reflection data was found, this method will at least load the precompiled * reflection data of any possible frozen package. Even if precompiled reflection * data could be loaded, FALSE will be returned in order to signal that other * packages still need to be reflected. * * @return boolean TRUE if reflection data could be loaded, otherwise FALSE */ protected function loadClassReflectionCompiletimeCache() { $data = $this->reflectionDataCompiletimeCache->get('ReflectionData'); if ($data !== false) { foreach ($data as $propertyName => $propertyValue) { $this->{$propertyName} = $propertyValue; } return true; } if (!$this->context->isDevelopment()) { return false; } $useIgBinary = extension_loaded('igbinary'); foreach ($this->packageManager->getActivePackages() as $packageKey => $package) { if (!$this->packageManager->isPackageFrozen($packageKey)) { continue; } $pathAndFilename = $this->getPrecompiledReflectionStoragePath() . $packageKey . '.dat'; if (!file_exists($pathAndFilename)) { continue; } $data = $useIgBinary ? igbinary_unserialize(file_get_contents($pathAndFilename)) : unserialize(file_get_contents($pathAndFilename)); foreach ($data as $propertyName => $propertyValue) { $this->{$propertyName} = Arrays::arrayMergeRecursiveOverrule($this->{$propertyName}, $propertyValue); } } return false; }