PhpiredisSocketConnectionTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\Connection;
  11. /**
  12. * @group ext-phpiredis
  13. * @requires extension phpiredis
  14. */
  15. class PhpiredisSocketConnectionTest extends PredisConnectionTestCase
  16. {
  17. const CONNECTION_CLASS = 'Predis\Connection\PhpiredisSocketConnection';
  18. // ******************************************************************** //
  19. // ---- INTEGRATION TESTS --------------------------------------------- //
  20. // ******************************************************************** //
  21. /**
  22. * @group connected
  23. * @expectedException \Predis\Connection\ConnectionException
  24. * @expectedExceptionMessage Cannot resolve the address of 'bogus.tld'.
  25. */
  26. public function testThrowsExceptionOnUnresolvableHostname()
  27. {
  28. $connection = $this->createConnectionWithParams(array('host' => 'bogus.tld'));
  29. $connection->connect();
  30. }
  31. /**
  32. * @medium
  33. * @group connected
  34. * @expectedException \Predis\Protocol\ProtocolException
  35. */
  36. public function testThrowsExceptionOnProtocolDesynchronizationErrors()
  37. {
  38. $connection = $this->createConnection();
  39. $socket = $connection->getResource();
  40. $connection->writeRequest($this->getCurrentProfile()->createCommand('ping'));
  41. socket_read($socket, 1);
  42. $connection->read();
  43. }
  44. }