public function testImageVersions() { $data = self::$storage->storeFile(__DIR__ . '/img.jpg', 'image.jpg', 'image/jpeg', array('thumb' => '30x30', 'medium' => '100x0')); $this->assertEquals(array('thumb' => 'image-30x30.jpg', 'medium' => 'image-100x0.jpg'), $data['versions']); list($width, $height) = getimagesize(__DIR__ . '/tmp-storage/image-30x30.jpg'); $this->assertEquals(30, $width); $this->assertEquals(30, $height); list($width, $height) = getimagesize(__DIR__ . '/tmp-storage/image-100x0.jpg'); $this->assertEquals(100, $width); $this->assertEquals(100, $height); self::$storage->removeVersions($data['name'], array('image-30x30.jpg')); $this->assertFalse(file_exists(__DIR__ . '/tmp-storage/image-30x30.jpg')); $this->assertTrue(file_exists(__DIR__ . '/tmp-storage/image-100x0.jpg')); self::$storage->generateVersion($data['name'], '10x40'); list($width, $height) = getimagesize(__DIR__ . '/tmp-storage/image-10x40.jpg'); $this->assertEquals(10, $width); $this->assertEquals(40, $height); }
/** * @param ObjectInterface $user * @param \Rocker\Object\User\UserFactory $factory * @param array $userFiles * @param \Rocker\Utils\FileStorage\StorageInterface $storage */ protected static function deleteAllFiles(ObjectInterface $user, UserFactory $factory, $userFiles, $storage) { foreach ($userFiles as $f) { if (!empty($f['versions'])) { $storage->removeVersions($f['name'], $f['versions']); } $storage->removeFile($f['name']); } $user->meta()->delete('files'); $factory->update($user); }