ResponseErrorTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /*
  3. * This file is part of the Predis package.
  4. *
  5. * (c) Daniele Alessandri <suppakilla@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Predis;
  11. use \PHPUnit_Framework_TestCase as StandardTestCase;
  12. /**
  13. *
  14. */
  15. class ResponseErrorTest extends StandardTestCase
  16. {
  17. const ERR_WRONG_KEY_TYPE = 'ERR Operation against a key holding the wrong kind of value';
  18. /**
  19. * @group disconnected
  20. */
  21. public function testResponseErrorClass()
  22. {
  23. $error = new ResponseError(self::ERR_WRONG_KEY_TYPE);
  24. $this->assertInstanceOf('Predis\IRedisServerError', $error);
  25. $this->assertInstanceOf('Predis\IReplyObject', $error);
  26. }
  27. /**
  28. * @group disconnected
  29. */
  30. public function testErrorMessage()
  31. {
  32. $error = new ResponseError(self::ERR_WRONG_KEY_TYPE);
  33. $this->assertEquals(self::ERR_WRONG_KEY_TYPE, $error->getMessage());
  34. }
  35. /**
  36. * @group disconnected
  37. */
  38. public function testErrorType()
  39. {
  40. $exception = new ResponseError(self::ERR_WRONG_KEY_TYPE);
  41. $this->assertEquals('ERR', $exception->getErrorType());
  42. }
  43. /**
  44. * @group disconnected
  45. */
  46. public function testToString()
  47. {
  48. $error = new ResponseError(self::ERR_WRONG_KEY_TYPE);
  49. $this->assertEquals(self::ERR_WRONG_KEY_TYPE, (string) $error);
  50. }
  51. }