/** * Test different storage methods */ public function testStorageMethods() { $backend = $this->getBackend(); // Test setFromContent $puppies1 = 'puppies'; $puppies1Tuple = $backend->setFromString($puppies1, 'pets/my-puppy.txt'); $this->assertEquals(array('Hash' => '2a17a9cb4be918774e73ba83bd1c1e7d000fdd53', 'Filename' => 'pets/my-puppy.txt', 'Variant' => ''), $puppies1Tuple); // Test setFromStream (seekable) $fish1 = realpath(__DIR__ . '/../model/testimages/test_image_high-quality.jpg'); $fish1Stream = fopen($fish1, 'r'); $fish1Tuple = $backend->setFromStream($fish1Stream, 'parent/awesome-fish.jpg'); fclose($fish1Stream); $this->assertEquals(array('Hash' => 'a870de278b475cb75f5d9f451439b2d378e13af1', 'Filename' => 'parent/awesome-fish.jpg', 'Variant' => ''), $fish1Tuple); // Test with non-seekable streams AssetStoreTest_SpyStore::$seekable_override = false; $fish2 = realpath(__DIR__ . '/../model/testimages/test_image_low-quality.jpg'); $fish2Stream = fopen($fish2, 'r'); $fish2Tuple = $backend->setFromStream($fish2Stream, 'parent/mediocre-fish.jpg'); fclose($fish2Stream); $this->assertEquals(array('Hash' => '33be1b95cba0358fe54e8b13532162d52f97421c', 'Filename' => 'parent/mediocre-fish.jpg', 'Variant' => ''), $fish2Tuple); AssetStoreTest_SpyStore::$seekable_override = null; }
/** * Reset defaults for this store */ public static function reset() { // Remove all files in this store if (self::$basedir) { $path = self::base_path(); if (file_exists($path)) { \Filesystem::removeFolder($path); } } self::$seekable_override = null; self::$basedir = null; }
/** * Reset defaults for this store */ public static function reset() { // Need flushing since it won't have any files left CacheGeneratedAssetHandler::flush(); // Remove all files in this store if (self::$basedir) { $path = self::base_path(); if (file_exists($path)) { SS_Filesystem::removeFolder($path); } } self::$seekable_override = null; self::$basedir = null; }