3
3
4
4
use PHPUnit \Framework \TestCase ;
5
5
6
- use Qiniu \Processing \Operation ;
7
6
use Qiniu \Processing \PersistentFop ;
7
+ use Qiniu \Storage \UploadManager ;
8
+ use Qiniu \Region ;
9
+ use Qiniu \Config ;
8
10
9
11
class PfopTest extends TestCase
10
12
{
11
- public function testPfop ()
13
+ private static function getConfig ()
14
+ {
15
+ // use this func to test in test env
16
+ // `null` means to use production env
17
+ return null ;
18
+ }
19
+
20
+ public function testPfopExecuteAndStatusWithSingleFop ()
12
21
{
13
22
global $ testAuth ;
14
23
$ bucket = 'testres ' ;
15
24
$ key = 'sintel_trailer.mp4 ' ;
16
- $ pfop = new PersistentFop ($ testAuth , null );
25
+ $ pfop = new PersistentFop ($ testAuth , self :: getConfig () );
17
26
18
27
$ fops = 'avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240 ' ;
19
28
list ($ id , $ error ) = $ pfop ->execute ($ bucket , $ key , $ fops );
@@ -24,7 +33,7 @@ public function testPfop()
24
33
}
25
34
26
35
27
- public function testPfops ()
36
+ public function testPfopExecuteAndStatusWithMultipleFops ()
28
37
{
29
38
global $ testAuth ;
30
39
$ bucket = 'testres ' ;
@@ -33,7 +42,7 @@ public function testPfops()
33
42
'avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240 ' ,
34
43
'vframe/jpg/offset/7/w/480/h/360 ' ,
35
44
);
36
- $ pfop = new PersistentFop ($ testAuth , null );
45
+ $ pfop = new PersistentFop ($ testAuth , self :: getConfig () );
37
46
38
47
list ($ id , $ error ) = $ pfop ->execute ($ bucket , $ key , $ fops );
39
48
$ this ->assertNull ($ error );
@@ -43,6 +52,71 @@ public function testPfops()
43
52
$ this ->assertNull ($ error );
44
53
}
45
54
55
+ public function testPfopWithIdleTimeType ()
56
+ {
57
+ global $ testAuth ;
58
+
59
+ $ bucket = 'testres ' ;
60
+ $ key = 'sintel_trailer.mp4 ' ;
61
+ $ persistentEntry = \Qiniu \entry ($ bucket , 'test-pfop-type_1 ' );
62
+ $ fops = 'avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240|saveas/ ' . $ persistentEntry ;
63
+ $ pfop = new PersistentFop ($ testAuth , self ::getConfig ());
64
+
65
+ list ($ id , $ error ) = $ pfop ->execute (
66
+ $ bucket ,
67
+ $ key ,
68
+ $ fops ,
69
+ null ,
70
+ null ,
71
+ false ,
72
+ 1
73
+ );
74
+ $ this ->assertNull ($ error );
75
+ list ($ status , $ error ) = $ pfop ->status ($ id );
76
+ $ this ->assertNotNull ($ status );
77
+ $ this ->assertNull ($ error );
78
+ $ this ->assertEquals (1 , $ status ['type ' ]);
79
+ $ this ->assertNotEmpty ($ status ['creationDate ' ]);
80
+ }
81
+
82
+ public function testPfopByUploadPolicy ()
83
+ {
84
+ global $ testAuth ;
85
+ $ bucket = 'testres ' ;
86
+ $ key = 'sintel_trailer.mp4 ' ;
87
+ $ persistentEntry = \Qiniu \entry ($ bucket , 'test-pfop-type_1 ' );
88
+ $ fops = 'avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240|saveas/ ' . $ persistentEntry ;
89
+
90
+ $ token = $ testAuth ->uploadToken (
91
+ $ bucket ,
92
+ $ key ,
93
+ 3600 ,
94
+ array (
95
+ 'persistentOps ' => $ fops ,
96
+ 'persistentType ' => 1
97
+ )
98
+ );
99
+ $ upManager = new UploadManager (self ::getConfig ());
100
+ list ($ ret , $ error ) = $ upManager ->putFile (
101
+ $ token ,
102
+ $ key ,
103
+ __file__,
104
+ null ,
105
+ 'text/plain ' ,
106
+ true
107
+ );
108
+ $ this ->assertNull ($ error );
109
+ $ this ->assertNotEmpty ($ ret ['persistentId ' ]);
110
+ $ id = $ ret ['persistentId ' ];
111
+
112
+ $ pfop = new PersistentFop ($ testAuth , self ::getConfig ());
113
+ list ($ status , $ error ) = $ pfop ->status ($ id );
114
+ $ this ->assertNotNull ($ status );
115
+ $ this ->assertNull ($ error );
116
+ $ this ->assertEquals (1 , $ status ['type ' ]);
117
+ $ this ->assertNotEmpty ($ status ['creationDate ' ]);
118
+ }
119
+
46
120
public function testMkzip ()
47
121
{
48
122
global $ testAuth ;
0 commit comments