@@ -52,7 +52,31 @@ public function testPfopExecuteAndStatusWithMultipleFops()
5252        $ this  ->assertNull ($ error );
5353    }
5454
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 )
5680    {
5781        global  $ testAuth ;
5882
@@ -69,32 +93,49 @@ public function testPfopWithIdleTimeType()
6993            null ,
7094            null ,
7195            false ,
72-             1 
96+             $ testParams [ ' type ' ] 
7397        );
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  ($ testPrams ['type ' ] == 1 ) {
105+                 $ this  ->assertEquals (1 , $ status ['type ' ]);
106+             }
107+             $ this  ->assertNotEmpty ($ status ['creationDate ' ]);
108+         } else  {
109+             $ this  ->assertNotNull ($ error );
110+         }
80111    }
81112
82-     public  function  testPfopByUploadPolicy ()
113+ 
114+     /** 
115+      * @dataProvider pfopTypeDataProvider 
116+      */ 
117+     public  function  testPfopByUploadPolicy ($ testParams )
83118    {
84119        global  $ testAuth ;
85120        $ bucket  = 'testres ' ;
86121        $ key  = 'sintel_trailer.mp4 ' ;
87122        $ persistentEntry  =  \Qiniu \entry ($ bucket , 'test-pfop-type_1 ' );
88123        $ fops  = 'avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240|saveas/ '  . $ persistentEntry ;
89124
125+         $ putPolicy  = array (
126+             'persistentOps '  => $ fops ,
127+             'persistentType '  => $ testParams ['type ' ]
128+         );
129+ 
130+         if  ($ testParams ['type ' ] == null ) {
131+             unset($ putPolicy ['persistentType ' ]);
132+         }
133+ 
90134        $ token  = $ testAuth ->uploadToken (
91135            $ bucket ,
92136            $ key ,
93137            3600 ,
94-             array (
95-                 'persistentOps '  => $ fops ,
96-                 'persistentType '  => 1 
97-             )
138+             $ putPolicy
98139        );
99140        $ upManager  = new  UploadManager (self ::getConfig ());
100141        list ($ ret , $ error ) = $ upManager ->putFile (
@@ -111,10 +152,17 @@ public function testPfopByUploadPolicy()
111152
112153        $ pfop  = new  PersistentFop ($ testAuth , self ::getConfig ());
113154        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+         }
118166    }
119167
120168    public  function  testMkzip ()
0 commit comments