function test19_delete_derived() { // should allow deleting all resources $this->markTestSkipped("Not enabled by default - remove this line to test"); Uploader::upload(self::LOGO_PNG, array("public_id" => self::$api_test_5, "eager" => array("transformation" => array("width" => 101, "crop" => "scale")))); $resource = $this->api->resource(self::$api_test_5); $this->assertNotEquals($resource, NULL); $this->assertEquals(count($resource["derived"]), 1); $this->api->delete_all_resources(array("keep_original" => True)); $resource = $this->api->resource(self::$api_test_5); $this->assertNotEquals($resource, NULL); $this->assertEquals(count($resource["derived"]), 0); }
public function get(RootFile $file) { try { $api = new Api(); $result = $api->resource(sprintf('%s/%s', $file->getUploaderPath(), $file->getBasename('.' . $file->getExtension()))); $file->setType($result['resource_type'] === 'image' ? 'image' : 'file'); if ($result['resource_type'] === 'image') { $config = $this->uploaderConfig->get('thumbnails'); $edition = new Edition("thumbnail", null, $file->getUploaderPath(), ['type' => 'image', 'height' => $config['height'], 'width' => $config['width'], 'crop' => $config['crop'], 'cloudinary_response' => $result], true); $edition->setUrl($this->resolveUrl($edition)); $file->addEdition($edition); } return $file; } catch (Api\NotFound $e) { return ['error' => 'S0001']; } }
function test34_restore() { \Cloudinary\Uploader::upload("tests/logo.png", array("public_id" => "api_test_restore", "backup" => TRUE)); $resource = $this->api->resource("api_test_restore"); $this->assertNotEquals($resource, NULL); $this->assertEquals($resource["bytes"], 3381); $this->api->delete_resources(array("api_test_restore")); $resource = $this->api->resource("api_test_restore"); $this->assertNotEquals($resource, NULL); $this->assertEquals($resource["bytes"], 0); $this->assertEquals($resource["placeholder"], TRUE); $response = $this->api->restore(array("api_test_restore")); $info = $response["api_test_restore"]; $this->assertNotEquals($info, NULL); $this->assertEquals($info["bytes"], 3381); $resource = $this->api->resource("api_test_restore"); $this->assertNotEquals($resource, NULL); $this->assertEquals($resource["bytes"], 3381); }
public function test_context() { //should allow sending context $context = array("caption" => "some caption", "alt" => "alternative"); $result = Uploader::upload(self::LOGO_PNG, array("context" => $context)); $api = new \Cloudinary\Api(); $info = $api->resource($result["public_id"], array("context" => true)); $this->assertEquals(array("custom" => $context), $info["context"]); }
/** * Get Resource data * @param string $path * @return array */ public function getResource($path) { return (array) $this->api->resource($path); }