@@ -6,21 +6,19 @@ class RsTest extends PHPUnit_Framework_TestCase
66{
77 public $ client ;
88 public $ bucket ;
9+ public $ key ;
910 public $ notExistKey = "not_exist " ;
10- public $ key1 ;
11- public $ key2 = "file_name_2 " ;
12- public $ key3 = "file_name_3 " ;
13- public $ key4 = "file_name_4 " ;
11+
1412 public function setUp ()
1513 {
1614 $ this ->client = new Qiniu_Client (null );
1715 $ this ->bucket = getenv ("QINIU_BUCKET_NAME " );
18- $ this ->key1 = getenv ("QINIU_KEY_NAME " );
16+ $ this ->key = getenv ("QINIU_KEY_NAME " );
1917 }
2018
2119 public function testStat ()
2220 {
23- list ($ ret , $ err ) = Qiniu_RS_Stat ($ this ->client , $ this ->bucket , $ this ->key1 );
21+ list ($ ret , $ err ) = Qiniu_RS_Stat ($ this ->client , $ this ->bucket , $ this ->key );
2422 $ this ->assertArrayHasKey ('hash ' , $ ret );
2523 $ this ->assertNull ($ err );
2624 list ($ ret , $ err ) = Qiniu_RS_Stat ($ this ->client , $ this ->bucket , $ this ->notExistKey );
@@ -30,22 +28,26 @@ public function testStat()
3028
3129 public function testDeleteMoveCopy ()
3230 {
33- Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ this ->key2 );
34- Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ this ->key3 );
31+ $ key2 = rand ();
32+ $ key3 = rand ();
33+ Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ key2 );
34+ Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ key3 );
3535
36- $ err = Qiniu_RS_Copy ($ this ->client , $ this ->bucket , $ this ->key1 , $ this ->bucket , $ this -> key2 );
36+ $ err = Qiniu_RS_Copy ($ this ->client , $ this ->bucket , $ this ->key , $ this ->bucket , $ key2 );
3737 $ this ->assertNull ($ err );
38- $ err = Qiniu_RS_Move ($ this ->client , $ this ->bucket , $ this -> key2 , $ this ->bucket , $ this -> key3 );
38+ $ err = Qiniu_RS_Move ($ this ->client , $ this ->bucket , $ key2 , $ this ->bucket , $ key3 );
3939 $ this ->assertNull ($ err );
40- $ err = Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ this -> key3 );
40+ $ err = Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ key3 );
4141 $ this ->assertNull ($ err );
42- $ err = Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ this -> key2 );
42+ $ err = Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ key2 );
4343 $ this ->assertNotNull ($ err , "delete key2 false " );
4444 }
4545
4646 public function testBatchStat ()
4747 {
48- $ entries = array (new Qiniu_RS_EntryPath ($ this ->bucket , $ this ->key1 ), new Qiniu_RS_EntryPath ($ this ->bucket , $ this ->key2 ));
48+ $ key2 = rand ();
49+ Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ key2 );
50+ $ entries = array (new Qiniu_RS_EntryPath ($ this ->bucket , $ this ->key ), new Qiniu_RS_EntryPath ($ this ->bucket , $ key2 ));
4951 list ($ ret , $ err ) = Qiniu_RS_BatchStat ($ this ->client , $ entries );
5052 $ this ->assertNotNull ($ err );
5153 $ this ->assertEquals ($ ret [0 ]['code ' ], 200 );
@@ -54,10 +56,13 @@ public function testBatchStat()
5456
5557 public function testBatchDeleteMoveCopy ()
5658 {
57- $ e1 = new Qiniu_RS_EntryPath ($ this ->bucket , $ this ->key1 );
58- $ e2 = new Qiniu_RS_EntryPath ($ this ->bucket , $ this ->key2 );
59- $ e3 = new Qiniu_RS_EntryPath ($ this ->bucket , $ this ->key3 );
60- $ e4 = new Qiniu_RS_EntryPath ($ this ->bucket , $ this ->key4 );
59+ $ key2 = rand ();
60+ $ key3 = rand ();
61+ $ key4 = rand ();
62+ $ e1 = new Qiniu_RS_EntryPath ($ this ->bucket , $ this ->key );
63+ $ e2 = new Qiniu_RS_EntryPath ($ this ->bucket , $ key2 );
64+ $ e3 = new Qiniu_RS_EntryPath ($ this ->bucket , $ key3 );
65+ $ e4 = new Qiniu_RS_EntryPath ($ this ->bucket , $ key4 );
6166 Qiniu_RS_BatchDelete ($ this ->client , array ($ e2 , $ e3 ,$ e4 ));
6267
6368 $ entryPairs = array (new Qiniu_RS_EntryPathPair ($ e1 , $ e2 ), new Qiniu_RS_EntryPathPair ($ e1 , $ e3 ));
0 commit comments