@@ -52,7 +52,31 @@ public function testPfopExecuteAndStatusWithMultipleFops()
52
52
$ this ->assertNull ($ error );
53
53
}
54
54
55
- public function testPfopWithIdleTimeType ()
55
+ public function pfopTypeDataProvider ()
56
+ {
57
+ return array (
58
+ array (
59
+ 'type ' => null
60
+ ),
61
+ array (
62
+ 'type ' => -1
63
+ ),
64
+ array (
65
+ 'type ' => 0
66
+ ),
67
+ array (
68
+ 'type ' => 1
69
+ ),
70
+ array (
71
+ 'type ' => 2
72
+ )
73
+ );
74
+ }
75
+
76
+ /**
77
+ * @dataProvider pfopTypeDataProvider
78
+ */
79
+ public function testPfopWithIdleTimeType ($ testParams )
56
80
{
57
81
global $ testAuth ;
58
82
@@ -69,32 +93,49 @@ public function testPfopWithIdleTimeType()
69
93
null ,
70
94
null ,
71
95
false ,
72
- 1
96
+ $ testParams [ ' type ' ]
73
97
);
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 ' ]);
98
+
99
+ if (in_array ($ testParams ['type ' ], array (null , 0 , 1 ))) {
100
+ $ this ->assertNull ($ error );
101
+ list ($ status , $ error ) = $ pfop ->status ($ id );
102
+ $ this ->assertNotNull ($ status );
103
+ $ this ->assertNull ($ error );
104
+ if ($ testParams ['type ' ] == 1 ) {
105
+ $ this ->assertEquals (1 , $ status ['type ' ]);
106
+ }
107
+ $ this ->assertNotEmpty ($ status ['creationDate ' ]);
108
+ } else {
109
+ $ this ->assertNotNull ($ error );
110
+ }
80
111
}
81
112
82
- public function testPfopByUploadPolicy ()
113
+
114
+ /**
115
+ * @dataProvider pfopTypeDataProvider
116
+ */
117
+ public function testPfopByUploadPolicy ($ testParams )
83
118
{
84
119
global $ testAuth ;
85
120
$ bucket = 'testres ' ;
86
121
$ key = 'sintel_trailer.mp4 ' ;
87
122
$ persistentEntry = \Qiniu \entry ($ bucket , 'test-pfop-type_1 ' );
88
123
$ fops = 'avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240|saveas/ ' . $ persistentEntry ;
89
124
125
+ $ putPolicy = array (
126
+ 'persistentOps ' => $ fops ,
127
+ 'persistentType ' => $ testParams ['type ' ]
128
+ );
129
+
130
+ if ($ testParams ['type ' ] == null ) {
131
+ unset($ putPolicy ['persistentType ' ]);
132
+ }
133
+
90
134
$ token = $ testAuth ->uploadToken (
91
135
$ bucket ,
92
136
$ key ,
93
137
3600 ,
94
- array (
95
- 'persistentOps ' => $ fops ,
96
- 'persistentType ' => 1
97
- )
138
+ $ putPolicy
98
139
);
99
140
$ upManager = new UploadManager (self ::getConfig ());
100
141
list ($ ret , $ error ) = $ upManager ->putFile (
@@ -111,10 +152,17 @@ public function testPfopByUploadPolicy()
111
152
112
153
$ pfop = new PersistentFop ($ testAuth , self ::getConfig ());
113
154
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 ' ]);
155
+
156
+ if (in_array ($ testParams ['type ' ], array (null , 0 , 1 ))) {
157
+ $ this ->assertNotNull ($ status );
158
+ $ this ->assertNull ($ error );
159
+ if ($ testParams ['type ' ] == 1 ) {
160
+ $ this ->assertEquals (1 , $ status ['type ' ]);
161
+ }
162
+ $ this ->assertNotEmpty ($ status ['creationDate ' ]);
163
+ } else {
164
+ $ this ->assertNotNull ($ error );
165
+ }
118
166
}
119
167
120
168
public function testMkzip ()
0 commit comments