Skip to content

Commit

Permalink
feat: pfop execute add fops and template checking
Browse files Browse the repository at this point in the history
  • Loading branch information
lihsai0 committed Oct 22, 2024
1 parent d3c4ed8 commit 796b8c7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Qiniu/Processing/PersistentFop.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public function execute(
if (is_array($fops)) {
$fops = implode(';', $fops);
}

if (!$fops && !$workflow_template_id) {
throw new \InvalidArgumentException('Must provide one of fops or template_id');
}

$params = array('bucket' => $bucket, 'key' => $key);
\Qiniu\setWithoutEmpty($params, 'fops', $fops);
\Qiniu\setWithoutEmpty($params, 'pipeline', $pipeline);
Expand Down
24 changes: 24 additions & 0 deletions tests/Qiniu/Tests/PfopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,30 @@ public function testPfopExecuteWithOptions()
}
}

public function testPfopWithInvalidArgument()
{
$bucket = self::$bucketName;
$key = 'qiniu.png';
$pfop = new PersistentFop(self::$testAuth, self::getConfig());
$err = null;
try {
$pfop->execute(
$bucket,
$key
);
} catch (\Exception $e) {
$err = $e;
}

$this->assertNotEmpty($err);
$this->assertTrue(
strpos(
$err->getMessage(),
'Must provide one of fops or template_id'
) !== false
);
}

public function testPfopWithUploadPolicy()
{
$bucket = self::$bucketName;
Expand Down

0 comments on commit 796b8c7

Please sign in to comment.