Skip to content

Commit d135773

Browse files
committed
add docs dir
1 parent 1d6f5e6 commit d135773

File tree

5 files changed

+34
-23
lines changed

5 files changed

+34
-23
lines changed

CHANGELOG.md

Whitespace-only changes.

docs/README.md

Whitespace-only changes.

qiniu/io.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class Qiniu_PutExtra
2323
function Qiniu_Put($upToken, $key, $body, $putExtra) // => ($data, $err)
2424
{
2525
global $QINIU_UP_HOST;
26+
if ($key == null) {
27+
$key = UNDEFINED_KEY;
28+
}
2629
$fields = array('key' => $key, 'token' => $upToken);
2730

2831
if ( $putExtra->CheckCrc == AUTO_CRC32 || $putExtra->CheckCrc == WITH_CRC32 ) {
@@ -37,6 +40,9 @@ function Qiniu_Put($upToken, $key, $body, $putExtra) // => ($data, $err)
3740
function Qiniu_PutFile($upToken, $key, $localFile, $putExtra) // => ($data, $err)
3841
{
3942
global $QINIU_UP_HOST;
43+
if ($key == null) {
44+
$key = UNDEFINED_KEY;
45+
}
4046
$fields = array('key' => $key, 'token' => $upToken, 'file' => '@' . $localFile);
4147

4248
if ( $putExtra->CheckCrc == AUTO_CRC32 ) {

tests/IoTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
class IoTest extends PHPUnit_Framework_TestCase
66
{
77
public $bucket;
8-
public $key = "iotest";
98
public $client;
109

1110
public function setUp()
@@ -16,29 +15,30 @@ public function setUp()
1615

1716
public function testPutFile()
1817
{
18+
$key = rand();
1919
$putPolicy = new Qiniu_RS_PutPolicy($this->bucket);
2020
$upToken = $putPolicy->Token(null);
2121
$putExtra = new Qiniu_PutExtra();
2222
$putExtra->CheckCrc = 1;
23-
list($ret, $err) = Qiniu_PutFile($upToken, $this->key, __File__, $putExtra);
23+
list($ret, $err) = Qiniu_PutFile($upToken, $key, __File__, $putExtra);
2424
$this->assertArrayHasKey('hash', $ret);
2525
$this->assertNull($err);
2626

27-
$err = Qiniu_RS_Delete($this->client, $this->bucket, $this->key);
27+
$err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
2828
$this->assertNull($err);
2929
}
3030

3131
public function testPut()
3232
{
33+
$key = rand();
3334
$putPolicy = new Qiniu_RS_PutPolicy($this->bucket);
3435
$upToken = $putPolicy->Token(null);
3536
$putExtra = new Qiniu_PutExtra();
36-
$putExtra->CheckCrc = 1;
37-
list($ret, $err) = Qiniu_Put($upToken, $this->key, "hello world!", $putExtra);
37+
list($ret, $err) = Qiniu_Put($upToken, $key, "hello world!", $putExtra);
3838
$this->assertArrayHasKey('hash', $ret);
3939
$this->assertNull($err);
4040

41-
$err = Qiniu_RS_Delete($this->client, $this->bucket, $this->key);
41+
$err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
4242
$this->assertNull($err);
4343
}
4444
}

tests/RsTest.php

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)