PhpiredisStreamConnectionTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 PhpiredisStreamConnectionTest extends PredisConnectionTestCase
  16. {
  17. const CONNECTION_CLASS = 'Predis\Connection\PhpiredisStreamConnection';
  18. /**
  19. * @group connected
  20. * @group slow
  21. * @requires PHP 5.4
  22. * @expectedException \Predis\Connection\ConnectionException
  23. */
  24. public function testThrowsExceptionOnReadWriteTimeout()
  25. {
  26. $profile = $this->getCurrentProfile();
  27. $connection = $this->createConnectionWithParams(array(
  28. 'read_write_timeout' => 0.5,
  29. ), true);
  30. $connection->executeCommand($profile->createCommand('brpop', array('foo', 3)));
  31. }
  32. /**
  33. * @medium
  34. * @group connected
  35. * @expectedException \Predis\Protocol\ProtocolException
  36. */
  37. public function testThrowsExceptionOnProtocolDesynchronizationErrors()
  38. {
  39. $connection = $this->createConnection();
  40. $stream = $connection->getResource();
  41. $connection->writeRequest($this->getCurrentProfile()->createCommand('ping'));
  42. stream_socket_recvfrom($stream, 1);
  43. $connection->read();
  44. }
  45. }