Skip to content

Commit

Permalink
Add support for on_success upload parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
const-cloudinary committed Aug 2, 2023
1 parent 5d29ee7 commit e5acd9e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Api/Upload/UploadTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public static function buildUploadParams($options)
'eager_async',
'eager_notification_url',
'eval',
'on_success',
'exif',
'faces',
'filename_override',
Expand Down
5 changes: 3 additions & 2 deletions tests/Integration/IntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ abstract class IntegrationTestCase extends CloudinaryTestCase
const TEST_DOCX_PATH = self::TEST_ASSETS_DIR . AssetTestCase::DOCX_NAME;
const TEST_VIDEO_PATH = self::TEST_ASSETS_DIR . AssetTestCase::VIDEO_NAME;
const TEST_LOGGING = ['logging' => ['test' => ['level' => 'debug']]];
const TEST_EVAL_STR
= 'if (resource_info["width"] < 450) { upload_options["quality_analysis"] = true }; ' .
const TEST_EVAL_STR = 'if (resource_info["width"] < 450) { upload_options["quality_analysis"] = true }; ' .
'upload_options["context"] = "width=" + resource_info["width"]';

const TEST_ON_SUCCESS_STR = 'current_asset.update({tags: ["autocaption"]});';

private static $TEST_ASSETS = [];

protected static $UNIQUE_UPLOAD_PRESET;
Expand Down
4 changes: 3 additions & 1 deletion tests/Unit/Upload/UploadApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Cloudinary\Configuration\Configuration;
use Cloudinary\Test\Helpers\MockUploadApi;
use Cloudinary\Test\Helpers\RequestAssertionsTrait;
use Cloudinary\Test\Integration\IntegrationTestCase;
use Cloudinary\Test\Unit\Asset\AssetTestCase;

/**
Expand All @@ -38,6 +39,7 @@ public function testVariousUploadParams()
'cinemagraph_analysis' => true,
'media_metadata' => true,
'visual_search' => true,
'on_success' => IntegrationTestCase::TEST_ON_SUCCESS_STR,
];

$mockUploadApi = new MockUploadApi();
Expand All @@ -49,7 +51,7 @@ public function testVariousUploadParams()
$lastOptions = $mockUploadApi->getApiClient()->getRequestMultipartOptions();

foreach ($params as $param => $value) {
self::assertEquals($value ? '1' : '0', $lastOptions[$param]);
self::assertEquals(is_bool($value) ? $value ? '1' : '0': $value, $lastOptions[$param]);
}
}

Expand Down

0 comments on commit e5acd9e

Please sign in to comment.