ExistResultTest.php 973 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace OSS\Tests;
  3. use OSS\Result\ExistResult;
  4. use OSS\Http\ResponseCore;
  5. use OSS\Core\OssException;
  6. class ExistResultTest extends \PHPUnit_Framework_TestCase
  7. {
  8. public function testParseValid200()
  9. {
  10. $response = new ResponseCore(array(), "", 200);
  11. $result = new ExistResult($response);
  12. $this->assertTrue($result->isOK());
  13. $this->assertEquals($result->getData(), true);
  14. }
  15. public function testParseInvalid404()
  16. {
  17. $response = new ResponseCore(array(), "", 404);
  18. $result = new ExistResult($response);
  19. $this->assertTrue($result->isOK());
  20. $this->assertEquals($result->getData(), false);
  21. }
  22. public function testInvalidResponse()
  23. {
  24. $response = new ResponseCore(array(), "", 300);
  25. try {
  26. new ExistResult($response);
  27. $this->assertTrue(false);
  28. } catch (OssException $e) {
  29. }
  30. }
  31. }