Skip to content

Commit 796b8c7

Browse files
committed
feat: pfop execute add fops and template checking
1 parent d3c4ed8 commit 796b8c7

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/Qiniu/Processing/PersistentFop.php

+5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public function execute(
7171
if (is_array($fops)) {
7272
$fops = implode(';', $fops);
7373
}
74+
75+
if (!$fops && !$workflow_template_id) {
76+
throw new \InvalidArgumentException('Must provide one of fops or template_id');
77+
}
78+
7479
$params = array('bucket' => $bucket, 'key' => $key);
7580
\Qiniu\setWithoutEmpty($params, 'fops', $fops);
7681
\Qiniu\setWithoutEmpty($params, 'pipeline', $pipeline);

tests/Qiniu/Tests/PfopTest.php

+24
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,30 @@ public function testPfopExecuteWithOptions()
167167
}
168168
}
169169

170+
public function testPfopWithInvalidArgument()
171+
{
172+
$bucket = self::$bucketName;
173+
$key = 'qiniu.png';
174+
$pfop = new PersistentFop(self::$testAuth, self::getConfig());
175+
$err = null;
176+
try {
177+
$pfop->execute(
178+
$bucket,
179+
$key
180+
);
181+
} catch (\Exception $e) {
182+
$err = $e;
183+
}
184+
185+
$this->assertNotEmpty($err);
186+
$this->assertTrue(
187+
strpos(
188+
$err->getMessage(),
189+
'Must provide one of fops or template_id'
190+
) !== false
191+
);
192+
}
193+
170194
public function testPfopWithUploadPolicy()
171195
{
172196
$bucket = self::$bucketName;

0 commit comments

Comments
 (0)