@@ -38,21 +38,22 @@ function find_by_attr($elements, $attr, $value) {
3838 return NULL ;
3939 }
4040
41- function test01_resource_types () { // should allow listing resource_types
42- $ result = $ this ->api ->resource_types ();
41+ function test01_resource_types () {
42+ // should allow listing resource_types
43+ $ result = $ this ->api ->resource_types ();
4344 $ this ->assertContains ("image " , $ result ["resource_types " ]);
4445 }
4546
4647 function test02_resources () {
4748 // should allow listing resources
48- $ result = $ this ->api ->resources ();
49+ $ result = $ this ->api ->resources ();
4950 $ resource = $ this ->find_by_attr ($ result ["resources " ], "public_id " , "api_test " );
5051 $ this ->assertNotEquals ($ resource , NULL );
5152 $ this ->assertEquals ($ resource ["type " ], "upload " );
5253 }
5354
5455 function test03_resources_cursor () {
55- // should allow listing resources with cursor
56+ // should allow listing resources with cursor
5657 $ result = $ this ->api ->resources (array ("max_results " =>1 ));
5758 $ this ->assertNotEquals ($ result ["resources " ], NULL );
5859 $ this ->assertEquals (count ($ result ["resources " ]), 1 );
@@ -65,14 +66,14 @@ function test03_resources_cursor() {
6566 }
6667
6768 function test04_resources_by_type () {
68- // should allow listing resources by type
69+ // should allow listing resources by type
6970 $ result = $ this ->api ->resources (array ("type " =>"upload " ));
7071 $ resource = $ this ->find_by_attr ($ result ["resources " ], "public_id " , "api_test " );
7172 $ this ->assertNotEquals ($ resource , NULL );
7273 }
7374
7475 function test05_resources_by_prefix () {
75- // should allow listing resources by prefix
76+ // should allow listing resources by prefix
7677 $ result = $ this ->api ->resources (array ("type " =>"upload " , "prefix " =>"api_test " ));
7778 $ func = function ($ resource ) {
7879 return $ resource ["public_id " ];
@@ -84,14 +85,14 @@ function test05_resources_by_prefix() {
8485 }
8586
8687 function test06_resources_tag () {
87- // should allow listing resources by tag
88+ // should allow listing resources by tag
8889 $ result = $ this ->api ->resources_by_tag ("api_test_tag " );
8990 $ resource = $ this ->find_by_attr ($ result ["resources " ], "public_id " , "api_test " );
9091 $ this ->assertNotEquals ($ resource , NULL );
9192 }
9293
9394 function test07_resource_metadata () {
94- // should allow get resource metadata
95+ // should allow get resource metadata
9596 $ resource = $ this ->api ->resource ("api_test " );
9697 $ this ->assertNotEquals ($ resource , NULL );
9798 $ this ->assertEquals ($ resource ["public_id " ], "api_test " );
@@ -100,7 +101,7 @@ function test07_resource_metadata() {
100101 }
101102
102103 function test08_delete_derived () {
103- // should allow deleting derived resource
104+ // should allow deleting derived resource
104105 \Cloudinary \Uploader::upload ("tests/logo.png " , array ("public_id " =>"api_test3 " , "eager " =>array ("transformation " =>array ("width " => 101 ,"crop " => "scale " ))));
105106 $ resource = $ this ->api ->resource ("api_test3 " );
106107 $ this ->assertNotEquals ($ resource , NULL );
@@ -150,14 +151,14 @@ function test09b_delete_resources_by_tag() {
150151
151152 function test10_tags () {
152153 // should allow listing tags
153- $ result = $ this ->api ->tags ();
154+ $ result = $ this ->api ->tags ();
154155 $ tags = $ result ["tags " ];
155156 $ this ->assertContains ("api_test_tag " , $ tags );
156157 }
157158
158159 function test11_tags_prefix () {
159160 // should allow listing tag by prefix
160- $ result = $ this ->api ->tags (array ("prefix " =>"api_test " ));
161+ $ result = $ this ->api ->tags (array ("prefix " =>"api_test " ));
161162 $ tags = $ result ["tags " ];
162163 $ this ->assertContains ("api_test_tag " , $ tags );
163164 $ result = $ this ->api ->tags (array ("prefix " =>"api_test_no_such_tag " ));
@@ -167,15 +168,15 @@ function test11_tags_prefix() {
167168
168169 function test12_transformations () {
169170 // should allow listing transformations
170- $ result = $ this ->api ->transformations ();
171+ $ result = $ this ->api ->transformations ();
171172 $ transformation = $ this ->find_by_attr ($ result ["transformations " ], "name " , "c_scale,w_100 " );
172173
173174 $ this ->assertNotEquals ($ transformation , NULL );
174175 $ this ->assertEquals ($ transformation ["used " ], TRUE );
175176 }
176177
177178 function test13_transformation_metadata () {
178- // should allow getting transformation metadata
179+ // should allow getting transformation metadata
179180 $ transformation = $ this ->api ->transformation ("c_scale,w_100 " );
180181 $ this ->assertNotEquals ($ transformation , NULL );
181182 $ this ->assertEquals ($ transformation ["info " ], array (array ("crop " => "scale " , "width " => 100 )));
@@ -185,7 +186,7 @@ function test13_transformation_metadata() {
185186 }
186187
187188 function test14_transformation_update () {
188- // should allow updating transformation allowed_for_strict
189+ // should allow updating transformation allowed_for_strict
189190 $ this ->api ->update_transformation ("c_scale,w_100 " , array ("allowed_for_strict " =>TRUE ));
190191 $ transformation = $ this ->api ->transformation ("c_scale,w_100 " );
191192 $ this ->assertNotEquals ($ transformation , NULL );
@@ -197,7 +198,7 @@ function test14_transformation_update() {
197198 }
198199
199200 function test15_transformation_create () {
200- // should allow creating named transformation
201+ // should allow creating named transformation
201202 $ this ->api ->create_transformation ("api_test_transformation " , array ("crop " => "scale " , "width " => 102 ));
202203 $ transformation = $ this ->api ->transformation ("api_test_transformation " );
203204 $ this ->assertNotEquals ($ transformation , NULL );
@@ -217,7 +218,7 @@ function test15a_transformation_unsafe_update() {
217218 }
218219
219220 function test16a_transformation_delete () {
220- // should allow deleting named transformation
221+ // should allow deleting named transformation
221222 $ this ->api ->create_transformation ("api_test_transformation2 " , array ("crop " => "scale " , "width " => 103 ));
222223 $ this ->api ->transformation ("api_test_transformation2 " );
223224 $ this ->api ->delete_transformation ("api_test_transformation2 " );
@@ -231,7 +232,7 @@ function test16b_transformation_delete() {
231232 }
232233
233234 function test17a_transformation_delete_implicit () {
234- // should allow deleting implicit transformation
235+ // should allow deleting implicit transformation
235236 $ this ->api ->transformation ("c_scale,w_100 " );
236237 $ this ->api ->delete_transformation ("c_scale,w_100 " );
237238 }
@@ -249,4 +250,16 @@ function test18_usage() {
249250 $ this ->assertNotEquals ($ result ["last_updated " ], NULL );
250251 }
251252
253+ function test19_delete_derived () {
254+ // should allow deleting all resources
255+ \Cloudinary \Uploader::upload ("tests/logo.png " , array ("public_id " =>"api_test5 " , "eager " =>array ("transformation " =>array ("width " => 101 ,"crop " => "scale " ))));
256+ $ resource = $ this ->api ->resource ("api_test5 " );
257+ $ this ->assertNotEquals ($ resource , NULL );
258+ $ this ->assertEquals (count ($ resource ["derived " ]), 1 );
259+ $ this ->api ->delete_all_resources (array ("keep_original " => True ));
260+ $ resource = $ this ->api ->resource ("api_test5 " );
261+ $ this ->assertNotEquals ($ resource , NULL );
262+ $ this ->assertEquals (count ($ resource ["derived " ]), 0 );
263+ }
264+
252265}
0 commit comments