CopyObjectResult.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace OSS\Tests;
  3. use OSS\Core\OssException;
  4. use OSS\Http\ResponseCore;
  5. use OSS\Result\CopyObjectResult;
  6. class CopyObjectResultTest extends \PHPUnit_Framework_TestCase
  7. {
  8. private $body = <<<BBBB
  9. <?xml version="1.0" encoding="utf-8"?>
  10. <CopyObjectResult>
  11. <LastModified>Fri, 24 Feb 2012 07:18:48 GMT</LastModified>
  12. <ETag>"5B3C1A2E053D763E1B002CC607C5A0FE"</ETag>
  13. </CopyObjectResult>
  14. BBBB;
  15. public function testNullResponse()
  16. {
  17. $response = null;
  18. try {
  19. new CopyObjectResult($response);
  20. $this->assertFalse(true);
  21. } catch (OssException $e) {
  22. $this->assertEquals('raw response is null', $e->getMessage());
  23. }
  24. }
  25. public function testOkResponse()
  26. {
  27. $header= array();
  28. $response = new ResponseCore($header, $this->body, 200);
  29. $result = new CopyObjectResult($response);
  30. $data = $result->getData();
  31. $this->assertTrue($result->isOK());
  32. $this->assertEquals("Fri, 24 Feb 2012 07:18:48 GMT", $data[0]);
  33. $this->assertEquals("\"5B3C1A2E053D763E1B002CC607C5A0FE\"", $data[1]);
  34. }
  35. public function testFailResponse()
  36. {
  37. $response = new ResponseCore(array(), "", 404);
  38. try {
  39. new CopyObjectResult($response);
  40. $this->assertFalse(true);
  41. } catch (OssException $e) {
  42. }
  43. }
  44. }