public function testWarmupDoesNotCallWarmupOnOptionalWarmersWhenEnableOptionalWarmersIsNotEnabled()
 {
     $warmer = $this->getCacheWarmerMock();
     $warmer->expects($this->once())->method('isOptional')->will($this->returnValue(true));
     $warmer->expects($this->never())->method('warmUp');
     $aggregate = new CacheWarmerAggregate(array($warmer));
     $aggregate->warmUp(self::$cacheDir);
 }
示例#2
0
 * @author    PrestaShop SA <*****@*****.**>
 * @copyright 2007-2015 PrestaShop SA
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
 */
use PrestaShop\PrestaShop\Adapter\ServiceLocator;
use PrestaShop\PrestaShop\Core\ContainerBuilder;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Filesystem\Filesystem;
$container_builder = new ContainerBuilder();
$container = $container_builder->build();
ServiceLocator::setServiceContainerInstance($container);
if (!file_exists(_PS_CACHE_DIR_)) {
    @mkdir(_PS_CACHE_DIR_);
    $warmer = new CacheWarmerAggregate([new PrestaShopBundle\Cache\LocalizationWarmer(_PS_VERSION_, 'en')]);
    $warmer->warmUp(_PS_CACHE_DIR_);
}
$configDirectory = __DIR__ . '/../app/config';
$phpParametersFilepath = $configDirectory . '/parameters.php';
$yamlParametersFilepath = $configDirectory . '/parameters.yml';
$filesystem = new Filesystem();
$exportPhpConfigFile = function ($config, $destination) use($filesystem) {
    return $filesystem->dumpFile($destination, '<?php return ' . var_export($config, true) . ';' . "\n");
};
// Bootstrap an application with parameters.yml, which has been installed before PHP parameters file support
if (!file_exists($phpParametersFilepath) && file_exists($yamlParametersFilepath)) {
    $parameters = Yaml::parse($yamlParametersFilepath);
    if ($exportPhpConfigFile($parameters, $phpParametersFilepath)) {
        $filesystem->dumpFile($yamlParametersFilepath, 'parameters:' . "\n");
    }