public static function init() { parent::init(); self::$enableRequestCache = (bool) IMAGE::$config['cache']; self::$defaultImagePath = (string) IMAGE::$config['defaultImage']; self::$defaultQuality = (int) IMAGE::$config['defaultQuality']; self::$browserCacheTTL = (int) IMAGE::$config['browserCacheLifetime']; self::$garbageCollectFileCacheMaxLifetime = (int) IMAGE::$config['serverCacheLifetime']; self::$cacheDir = (string) IMAGE::$config['cacheDir']; self::$pathToCacheDir = (string) IMAGE::$config['pathToCacheDir']; if (!is_dir(self::$pathToCacheDir)) { $cachePath = explode('/', self::$cacheDir); $count = count($cachePath); $currentPath = IMAGE::$config['documentRoot']; for ($i = 0; $i < $count; $i++) { if ($cachePath[$i] !== '') { $currentPath = $currentPath . '/' . $cachePath[$i]; if (!is_dir($currentPath)) { mkdir($currentPath); } } } chmod(self::$pathToCacheDir, 0777); } }
/** * @return void */ protected function setUp() { $this->slir = new SLIR(); SLIRConfig::$defaultImagePath = null; SLIRConfig::$forceQueryString = false; SLIRConfig::$enableErrorImages = false; SLIRConfig::$defaultCropper = SLIR::CROP_CLASS_CENTERED; SLIRConfig::$copyEXIF = false; SLIRConfig::$maxMemoryToAllocate = -1; // Try to fix documentRoot for CLI SLIRConfig::$documentRoot = realpath(__DIR__ . '/../../'); }
/** * @test */ public function initializeUnspecifiedImageWithDefaultImageOnlyWidth() { $request = new SLIRRequest(); SLIRConfig::$defaultImagePath = '/slir/Test/images/camera-logo.png'; $_SERVER['REQUEST_URI'] = '/slir/w100/'; $request->initialize(); $this->assertSame($request->width, 100); $this->assertSame($request->path, '/slir/Test/images/camera-logo.png'); SLIRConfig::$defaultImagePath = null; }