PutSetDeleteResultTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace OSS\Tests;
  3. use OSS\Core\OssException;
  4. use OSS\Http\ResponseCore;
  5. use OSS\Result\PutSetDeleteResult;
  6. class ResultTest extends \PHPUnit_Framework_TestCase
  7. {
  8. public function testNullResponse()
  9. {
  10. $response = null;
  11. try {
  12. new PutSetDeleteResult($response);
  13. $this->assertFalse(true);
  14. } catch (OssException $e) {
  15. $this->assertEquals('raw response is null', $e->getMessage());
  16. }
  17. }
  18. public function testOkResponse()
  19. {
  20. $response = new ResponseCore(array(), "", 200);
  21. $result = new PutSetDeleteResult($response);
  22. $this->assertTrue($result->isOK());
  23. $this->assertNull($result->getData());
  24. $this->assertNotNull($result->getRawResponse());
  25. }
  26. public function testFailResponse()
  27. {
  28. $response = new ResponseCore(array(), "", 301);
  29. try {
  30. new PutSetDeleteResult($response);
  31. $this->assertFalse(true);
  32. } catch (OssException $e) {
  33. }
  34. }
  35. public function setUp()
  36. {
  37. }
  38. public function tearDown()
  39. {
  40. }
  41. }