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