PhpiredisSocketConnectionTest.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. * @group disconnected
  20. * @expectedException \InvalidArgumentException
  21. * @expectedExceptionMessage Invalid scheme: 'tls'.
  22. */
  23. public function testSupportsSchemeTls()
  24. {
  25. $connection = $this->createConnectionWithParams(array('scheme' => 'tls'));
  26. $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection);
  27. }
  28. /**
  29. * @group disconnected
  30. * @expectedException \InvalidArgumentException
  31. * @expectedExceptionMessage Invalid scheme: 'rediss'.
  32. */
  33. public function testSupportsSchemeRediss()
  34. {
  35. $connection = $this->createConnectionWithParams(array('scheme' => 'rediss'));
  36. $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection);
  37. }
  38. // ******************************************************************** //
  39. // ---- INTEGRATION TESTS --------------------------------------------- //
  40. // ******************************************************************** //
  41. /**
  42. * @group connected
  43. * @expectedException \Predis\Connection\ConnectionException
  44. * @expectedExceptionMessage Cannot resolve the address of 'bogus.tld'.
  45. */
  46. public function testThrowsExceptionOnUnresolvableHostname()
  47. {
  48. $connection = $this->createConnectionWithParams(array('host' => 'bogus.tld'));
  49. $connection->connect();
  50. }
  51. /**
  52. * @medium
  53. * @group connected
  54. * @expectedException \Predis\Protocol\ProtocolException
  55. */
  56. public function testThrowsExceptionOnProtocolDesynchronizationErrors()
  57. {
  58. $connection = $this->createConnection();
  59. $socket = $connection->getResource();
  60. $connection->writeRequest($this->getCurrentProfile()->createCommand('ping'));
  61. socket_read($socket, 1);
  62. $connection->read();
  63. }
  64. }