UploadPartResultTest.php 958 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace OSS\Tests;
  3. use OSS\Core\OssException;
  4. use OSS\Result\UploadPartResult;
  5. use OSS\Http\ResponseCore;
  6. class UploadPartResultTest extends \PHPUnit_Framework_TestCase
  7. {
  8. private $validHeader = array('etag' => '7265F4D211B56873A381D321F586E4A9');
  9. private $invalidHeader = array();
  10. public function testParseValidHeader()
  11. {
  12. $response = new ResponseCore($this->validHeader, "", 200);
  13. $result = new UploadPartResult($response);
  14. $eTag = $result->getData();
  15. $this->assertEquals('7265F4D211B56873A381D321F586E4A9', $eTag);
  16. }
  17. public function testParseInvalidHeader()
  18. {
  19. $response = new ResponseCore($this->invalidHeader, "", 200);
  20. try {
  21. new UploadPartResult($response);
  22. $this->assertTrue(false);
  23. } catch (OssException $e) {
  24. $this->assertEquals('cannot get ETag', $e->getMessage());
  25. }
  26. }
  27. }