|
| 1 | +<?php |
| 2 | + |
| 3 | +require_once("bootstrap.php"); |
| 4 | + |
| 5 | +class RsUtilsTest extends PHPUnit_Framework_TestCase |
| 6 | +{ |
| 7 | + public $bucket; |
| 8 | + public $client; |
| 9 | + |
| 10 | + public function setUp() |
| 11 | + { |
| 12 | + initKeys(); |
| 13 | + $this->client = new Qiniu_MacHttpClient(null); |
| 14 | + $this->bucket = getenv("QINIU_BUCKET_NAME"); |
| 15 | + } |
| 16 | + |
| 17 | + public function testPutFile() |
| 18 | + { |
| 19 | + $key = 'testPutFile' . getTid(); |
| 20 | + $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); |
| 21 | + |
| 22 | + $putExtra = new Qiniu_PutExtra(); |
| 23 | + $putExtra->CheckCrc = 1; |
| 24 | + list($ret, $err) = Qiniu_RS_PutFile($this->client, $this->bucket, $key, __file__, $putExtra); |
| 25 | + $this->assertNull($err); |
| 26 | + $this->assertArrayHasKey('hash', $ret); |
| 27 | + var_dump($ret); |
| 28 | + |
| 29 | + list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $key); |
| 30 | + $this->assertNull($err); |
| 31 | + var_dump($ret); |
| 32 | + |
| 33 | + $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); |
| 34 | + $this->assertNull($err); |
| 35 | + } |
| 36 | + |
| 37 | + public function testPut() |
| 38 | + { |
| 39 | + $key = 'testPut' . getTid(); |
| 40 | + $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); |
| 41 | + |
| 42 | + list($ret, $err) = Qiniu_RS_Put($this->client, $this->bucket, $key, "hello world!", null); |
| 43 | + $this->assertNull($err); |
| 44 | + $this->assertArrayHasKey('hash', $ret); |
| 45 | + var_dump($ret); |
| 46 | + |
| 47 | + list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $key); |
| 48 | + $this->assertNull($err); |
| 49 | + var_dump($ret); |
| 50 | + |
| 51 | + $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); |
| 52 | + $this->assertNull($err); |
| 53 | + } |
| 54 | +} |
| 55 | + |
0 commit comments