@@ -52,7 +52,30 @@ public function testPfopExecuteAndStatusWithMultipleFops()
5252 $ this ->assertNull ($ error );
5353 }
5454
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 )
5679 {
5780 global $ testAuth ;
5881
@@ -69,32 +92,49 @@ public function testPfopWithIdleTimeType()
6992 null ,
7093 null ,
7194 false ,
72- 1
95+ $ testParams [ ' type ' ]
7396 );
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+ }
80110 }
81111
82- public function testPfopByUploadPolicy ()
112+
113+ /**
114+ * @dataProvider pfopTypeDataProvider
115+ */
116+ public function testPfopByUploadPolicy ($ testParams )
83117 {
84118 global $ testAuth ;
85119 $ bucket = 'testres ' ;
86120 $ key = 'sintel_trailer.mp4 ' ;
87121 $ persistentEntry = \Qiniu \entry ($ bucket , 'test-pfop-type_1 ' );
88122 $ fops = 'avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240|saveas/ ' . $ persistentEntry ;
89123
124+ $ putPolicy = array (
125+ 'persistentOps ' => $ fops ,
126+ 'persistentType ' => $ testParams ['type ' ]
127+ );
128+
129+ if ($ testParams ['type ' ] == null ) {
130+ unset($ putPolicy ['persistentType ' ]);
131+ }
132+
90133 $ token = $ testAuth ->uploadToken (
91134 $ bucket ,
92135 $ key ,
93136 3600 ,
94- array (
95- 'persistentOps ' => $ fops ,
96- 'persistentType ' => 1
97- )
137+ $ putPolicy
98138 );
99139 $ upManager = new UploadManager (self ::getConfig ());
100140 list ($ ret , $ error ) = $ upManager ->putFile (
@@ -111,10 +151,17 @@ public function testPfopByUploadPolicy()
111151
112152 $ pfop = new PersistentFop ($ testAuth , self ::getConfig ());
113153 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+ }
118165 }
119166
120167 public function testMkzip ()
0 commit comments