diff --git a/src/Qiniu/Processing/PersistentFop.php b/src/Qiniu/Processing/PersistentFop.php index acb9f15e..8dca4a9f 100644 --- a/src/Qiniu/Processing/PersistentFop.php +++ b/src/Qiniu/Processing/PersistentFop.php @@ -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); diff --git a/tests/Qiniu/Tests/PfopTest.php b/tests/Qiniu/Tests/PfopTest.php index 1fbce7e8..77d06ecb 100755 --- a/tests/Qiniu/Tests/PfopTest.php +++ b/tests/Qiniu/Tests/PfopTest.php @@ -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;