Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,13 @@ function transformation($transformation, $options=array()) {

function delete_transformation($transformation, $options=array()) {
$uri = array("transformations", $this->transformation_string($transformation));
return $this->call_api("delete", $uri, array(), $options);
$params = array();
if (isset($options["invalidate"])) {
$params["invalidate"] = $options["invalidate"];
}
return $this->call_api("delete", $uri, $params, $options);
}

# updates - currently only supported update is the "allowed_for_strict" boolean flag
function update_transformation($transformation, $updates=array(), $options=array()) {
$uri = array("transformations", $this->transformation_string($transformation));
Expand Down
25 changes: 24 additions & 1 deletion tests/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,29 @@ function test17a_transformation_delete_implicit() {

}

function test_transformation_delete_with_invalidate() {
// should allow deleting and invalidating a transformation
Curl::mockApi($this);

// should pass 'invalidate' param when 'invalidate' is set to true
$this->api->delete_transformation("c_scale,w_100,a_90", array("invalidate" => true));
assertUrl($this, "/transformations/c_scale,w_100,a_90");
assertDelete($this);
assertParam($this, "invalidate", "1");

// should pass 'invalidate' param when 'invalidate' is set to false
$this->api->delete_transformation("c_scale,w_100,a_90", array("invalidate" => false));
assertUrl($this, "/transformations/c_scale,w_100,a_90");
assertDelete($this);
assertParam($this, "invalidate", "");

// should not pass 'invalidate' param if not set
$this->api->delete_transformation("c_scale,w_100,a_90");
assertUrl($this, "/transformations/c_scale,w_100,a_90");
assertDelete($this);
assertNoParam($this, "invalidate");
}

function test18_usage() {
// should allow listing resource_types
$result = $this->api->usage();
Expand Down Expand Up @@ -684,4 +707,4 @@ function test_update_parameters(){
}

}
}
}
6 changes: 5 additions & 1 deletion tests/TestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ function assertParam($test, $name, $expectedValue = NULL, $message = '') {
}
}

function assertNoParam($test, $name, $message = '') {
$fields = Curl::$instance->fields();
$test->assertArrayNotHasKey($name, $fields, $message);
}

function assertPost($test, $message = "http method should be POST") {
$test->assertEquals("POST", Curl::$instance->http_method(), $message);
Expand All @@ -202,4 +206,4 @@ function assertUrl($test, $path, $message = ''){
$cloud_name = \Cloudinary::config_get("cloud_name");
$test->assertEquals("/v1_1/" . $cloud_name . $path, Curl::$instance->url_path(), $message);
}
}
}