Skip to content

Commit 89645fd

Browse files
committed
test case pass
1 parent 3a62355 commit 89645fd

File tree

4 files changed

+37
-54
lines changed

4 files changed

+37
-54
lines changed

src/Qiniu/Processing/Operation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ public function __construct($domain, $auth = null, $token_expire = 3600)
2424
* 对资源文件进行处理
2525
*
2626
* @param $key 待处理的资源文件名
27-
* @param $fops string|array fop操作,多次fop操作以array的形式传入。
27+
* @param $fops string|array fop操作,多次fop操作以array的形式传入。
2828
* eg. imageView2/1/w/200/h/200, imageMogr2/thumbnail/!75px
2929
*
3030
* @return array[] 文件处理后的结果及错误。
31-
*
31+
*
3232
* @link http://developer.qiniu.com/docs/v6/api/reference/fop/
3333
*/
3434
public function execute($key, $fops)
@@ -47,7 +47,7 @@ public function execute($key, $fops)
4747
public function buildUrl($key, $fops)
4848
{
4949
if (is_array($fops)) {
50-
implode('|', $fops)
50+
$fops = implode('|', $fops);
5151
}
5252

5353
$url = "http://$this->domain/$key?$fops";
@@ -57,4 +57,4 @@ public function buildUrl($key, $fops)
5757

5858
return $url;
5959
}
60-
}
60+
}

src/Qiniu/Processing/PersistentFop.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,20 @@ public function __construct($auth, $bucket, $pipeline = null, $notify_url = null
4646
* 对资源文件进行异步持久化处理
4747
*
4848
* @param $key 待处理的源文件
49-
* @param $fops string|array 待处理的pfop操作,多个pfop操作以array的形式传入。
49+
* @param $fops string|array 待处理的pfop操作,多个pfop操作以array的形式传入。
5050
* eg. avthumb/mp3/ab/192k, vframe/jpg/offset/7/w/480/h/360
5151
*
5252
* @return array[] 返回持久化处理的persistentId, 和返回的错误。
53-
*
53+
*
5454
* @link http://developer.qiniu.com/docs/v6/api/reference/fop/
5555
*/
5656
public function execute($key, $fops)
5757
{
5858
if (is_array($fops)) {
59-
$ops = implode(';', $fops);
59+
$fops = implode(';', $fops);
6060
}
6161

62-
$params = array('bucket' => $this->bucket, 'key' => $key, 'fops' => $ops);
62+
$params = array('bucket' => $this->bucket, 'key' => $key, 'fops' => $fops);
6363
if (!empty($this->pipeline)) {
6464
$params['pipeline'] = $this->pipeline;
6565
}

tests/Qiniu/Tests/FopTest.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class FopTest extends \PHPUnit_Framework_TestCase
99
public function testExifPub()
1010
{
1111
$fop = new Operation('testres.qiniudn.com');
12-
list($exif, $error) = $fop->exif('gogopher.jpg');
12+
list($exif, $error) = $fop->execute('gogopher.jpg', 'exif');
1313
$this->assertNull($error);
1414
$this->assertNotNull($exif);
1515
}
@@ -18,8 +18,20 @@ public function testExifPrivate()
1818
{
1919
global $testAuth;
2020
$fop = new Operation('private-res.qiniudn.com', $testAuth);
21-
list($exif, $error) = $fop->exif('noexif.jpg');
21+
list($exif, $error) = $fop->execute('noexif.jpg', 'exif');
2222
$this->assertNotNull($error);
2323
$this->assertNull($exif);
2424
}
25+
26+
public function testbuildUrl()
27+
{
28+
$fops = 'imageView2/2/h/200';
29+
$fop = new Operation('testres.qiniudn.com');
30+
$url = $fop->buildUrl('gogopher.jpg', $fops);
31+
$this->assertEquals($url, 'http://testres.qiniudn.com/gogopher.jpg?imageView2/2/h/200');
32+
33+
$fops = array('imageView2/2/h/200', 'imageInfo');
34+
$url = $fop->buildUrl('gogopher.jpg', $fops);
35+
$this->assertEquals($url, 'http://testres.qiniudn.com/gogopher.jpg?imageView2/2/h/200|imageInfo');
36+
}
2537
}

tests/Qiniu/Tests/PfopTest.php

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,61 +9,32 @@ class PfopTest extends \PHPUnit_Framework_TestCase
99
public function testExecute1()
1010
{
1111
global $testAuth;
12-
$pfop = new PersistentFop($testAuth, 'testres', 'sdktest', true);
13-
$op = Operation::saveas('avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240', 'phpsdk', 'pfoptest');
14-
$ops = array();
15-
array_push($ops, $op);
16-
list($id, $error) = $pfop->execute('sintel_trailer.mp4', $ops);
12+
$bucket = 'testres';
13+
$key = 'sintel_trailer.mp4';
14+
$pfop = new PersistentFop($testAuth, $bucket);
15+
16+
$fops = 'avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240';
17+
list($id, $error) = $pfop->execute($key, $fops);
1718
$this->assertNull($error);
1819
list($status, $error) = PersistentFop::status($id);
1920
$this->assertNotNull($status);
2021
$this->assertNull($error);
2122
}
2223

23-
public function testAvthumb()
24-
{
25-
global $testAuth;
26-
$pfop = new PersistentFop($testAuth, 'testres', 'sdktest', true);
27-
$options = array(
28-
'segtime' => 10,
29-
'vcodec' => 'libx264',
30-
's' => '320x240'
31-
);
32-
list($id, $error) = $pfop->avthumb('sintel_trailer.mp4', 'm3u8', $options, 'phpsdk', 'avthumtest');
33-
$this->assertNull($error);
34-
list($status, $error) = PersistentFop::status($id);
35-
$this->assertNotNull($status);
36-
$this->assertNull($error);
37-
}
3824

3925
public function testExecute2()
4026
{
4127
global $testAuth;
42-
$pfop = new PersistentFop($testAuth, 'testres', 'sdktest', true);
43-
$url_src1 = 'http://testres.qiniudn.com/gogopher.jpg';
44-
$url_en1 = \Qiniu\base64_urlSafeEncode($url_src1);
45-
$url_alias_en1 = \Qiniu\base64_urlSafeEncode('g.jpg');
46-
$url_en2 = $url_en1;
47-
$fop = "mkzip/2/url/$url_en1/alias/$url_alias_en1/url/$url_en2";
48-
$op = Operation::saveas($fop, 'phpsdk', 'mkziptest');
49-
$ops = array();
50-
array_push($ops, $op);
51-
list($id, $error) = $pfop->execute('sintel_trailer.mp4', $ops);
52-
$this->assertNull($error);
53-
list($status, $error) = PersistentFop::status($id);
54-
$this->assertNotNull($status);
55-
$this->assertNull($error);
56-
}
28+
$bucket = 'testres';
29+
$key = 'sintel_trailer.mp4';
30+
$fops = array(
31+
'avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240',
32+
'vframe/jpg/offset/7/w/480/h/360',
33+
);
34+
$pfop = new PersistentFop($testAuth, $bucket);
5735

58-
public function testMkzip()
59-
{
60-
global $testAuth;
61-
$pfop = new PersistentFop($testAuth, 'testres', 'sdktest', true);
62-
$urls = array(
63-
'http://testres.qiniudn.com/gogopher.jpg' => 'g.jpg',
64-
'http://testres.qiniudn.com/gogopher.jpg'
65-
);
66-
list($id, $error) = $pfop->mkzip('sintel_trailer.mp4', $urls, 'phpsdk', 'mkziptest2.zip');
36+
list($id, $error) = $pfop->execute($key, $fops);
37+
var_dump($id);
6738
$this->assertNull($error);
6839
list($status, $error) = PersistentFop::status($id);
6940
$this->assertNotNull($status);

0 commit comments

Comments
 (0)