StatusTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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\Response;
  11. use PredisTestCase;
  12. /**
  13. *
  14. */
  15. class StatusTest extends PredisTestCase
  16. {
  17. /**
  18. * @group disconnected
  19. */
  20. public function testStatusResponse()
  21. {
  22. $status = new Status('OK');
  23. $this->assertInstanceOf('Predis\Response\ResponseInterface', $status);
  24. $this->assertSame('OK', $status->getPayload());
  25. }
  26. /**
  27. * @group disconnected
  28. */
  29. public function testStatusToString()
  30. {
  31. $queued = new Status('OK');
  32. $this->assertSame('OK', (string) $queued);
  33. $this->assertEquals('OK', $queued);
  34. }
  35. /**
  36. * @group disconnected
  37. */
  38. public function testStaticGetMethod()
  39. {
  40. $this->assertInstanceOf('Predis\Response\Status', $response = Status::get('OK'));
  41. $this->assertEquals('OK', $response);
  42. $this->assertInstanceOf('Predis\Response\Status', $response = Status::get('QUEUED'));
  43. $this->assertEquals('QUEUED', $response);
  44. $this->assertInstanceOf('Predis\Response\Status', $response = Status::get('PONG'));
  45. $this->assertEquals('PONG', $response);
  46. }
  47. /**
  48. * @group disconnected
  49. */
  50. public function testStaticGetMethodCachesOnlyCommonStatuses()
  51. {
  52. $response = Status::get('OK');
  53. $this->assertSame($response, Status::get('OK'));
  54. $response = Status::get('QUEUED');
  55. $this->assertSame($response, Status::get('QUEUED'));
  56. $response = Status::get('PONG');
  57. $this->assertNotSame($response, Status::get('PONG'));
  58. }
  59. }