File tree Expand file tree Collapse file tree 2 files changed +68
-0
lines changed
Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,27 @@ public function createFolder($path)
8787 return $ this ->apiClient ->post ($ uri );
8888 }
8989
90+ /**
91+ * Renames folder.
92+ *
93+ * @param string $fromPath The full path of an existing asset folder.
94+ * @param string $toPath The full path of the new asset folder.
95+ *
96+ * @return ApiResponse
97+ *
98+ * @throws ApiError
99+ *
100+ * @see https://cloudinary.com/documentation/admin_api#rename_folder
101+ */
102+ public function renameFolder ($ fromPath , $ toPath )
103+ {
104+ $ uri = [ApiEndPoint::FOLDERS , $ fromPath ];
105+
106+ $ params = ['to_folder ' => $ toPath ];
107+
108+ return $ this ->apiClient ->put ($ uri , $ params );
109+ }
110+
90111 /**
91112 * Deletes an empty folder.
92113 *
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * This file is part of the Cloudinary PHP package.
4+ *
5+ * (c) Cloudinary
6+ *
7+ * For the full copyright and license information, please view the LICENSE
8+ * file that was distributed with this source code.
9+ */
10+
11+ namespace Cloudinary \Test \Unit \Admin ;
12+
13+ use Cloudinary \Api \Exception \ApiError ;
14+ use Cloudinary \Configuration \Configuration ;
15+ use Cloudinary \Test \Helpers \MockAdminApi ;
16+ use Cloudinary \Test \Helpers \RequestAssertionsTrait ;
17+ use Cloudinary \Test \Unit \UnitTestCase ;
18+
19+ /**
20+ * Class FoldersTest
21+ */
22+ final class FoldersTest extends UnitTestCase
23+ {
24+ use RequestAssertionsTrait;
25+
26+ /**
27+ * Test rename folder.
28+ *
29+ * @throws ApiError
30+ */
31+ public function testRenameFolder ()
32+ {
33+ $ mockAdminApi = new MockAdminApi ();
34+ $ mockAdminApi ->renameFolder (self ::API_TEST_ASSET_ID , self ::API_TEST_ASSET_ID2 );
35+
36+ $ lastRequest = $ mockAdminApi ->getMockHandler ()->getLastRequest ();
37+
38+ self ::assertRequestPut ($ lastRequest );
39+ self ::assertRequestUrl ($ lastRequest , '/folders/ ' . self ::API_TEST_ASSET_ID );
40+ self ::assertRequestBodySubset (
41+ $ lastRequest ,
42+ [
43+ "to_folder " => self ::API_TEST_ASSET_ID2 ,
44+ ]
45+ );
46+ }
47+ }
You can’t perform that action at this time.
0 commit comments