StreamConnectionTest.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. *
  13. */
  14. class StreamConnectionTest extends PredisConnectionTestCase
  15. {
  16. const CONNECTION_CLASS = 'Predis\Connection\StreamConnection';
  17. // ******************************************************************** //
  18. // ---- INTEGRATION TESTS --------------------------------------------- //
  19. // ******************************************************************** //
  20. /**
  21. * @group connected
  22. */
  23. public function testPersistentParameterWithFalseLikeValues()
  24. {
  25. if ($this->isHHVM()) {
  26. $this->markTestSkipped('This test does not currently work on HHVM.');
  27. }
  28. $connection1 = $this->createConnectionWithParams(array('persistent' => 0));
  29. $this->assertNonPersistentConnection($connection1);
  30. $connection2 = $this->createConnectionWithParams(array('persistent' => false));
  31. $this->assertNonPersistentConnection($connection2);
  32. $connection3 = $this->createConnectionWithParams(array('persistent' => '0'));
  33. $this->assertNonPersistentConnection($connection3);
  34. $connection4 = $this->createConnectionWithParams(array('persistent' => 'false'));
  35. $this->assertNonPersistentConnection($connection4);
  36. }
  37. /**
  38. * @group connected
  39. */
  40. public function testPersistentParameterWithTrueLikeValues()
  41. {
  42. if ($this->isHHVM()) {
  43. $this->markTestSkipped('This test does not currently work on HHVM.');
  44. }
  45. $connection1 = $this->createConnectionWithParams(array('persistent' => 1));
  46. $this->assertPersistentConnection($connection1);
  47. $connection2 = $this->createConnectionWithParams(array('persistent' => true));
  48. $this->assertPersistentConnection($connection2);
  49. $connection3 = $this->createConnectionWithParams(array('persistent' => '1'));
  50. $this->assertPersistentConnection($connection3);
  51. $connection4 = $this->createConnectionWithParams(array('persistent' => 'true'));
  52. $this->assertPersistentConnection($connection4);
  53. $connection1->disconnect();
  54. }
  55. /**
  56. * @group connected
  57. */
  58. public function testPersistentConnectionsToSameNodeShareResource()
  59. {
  60. if ($this->isHHVM()) {
  61. $this->markTestSkipped('This test does not currently work on HHVM.');
  62. }
  63. $connection1 = $this->createConnectionWithParams(array('persistent' => true));
  64. $connection2 = $this->createConnectionWithParams(array('persistent' => true));
  65. $this->assertPersistentConnection($connection1);
  66. $this->assertPersistentConnection($connection2);
  67. $this->assertSame($connection1->getResource(), $connection2->getResource());
  68. $connection1->disconnect();
  69. }
  70. /**
  71. * @group connected
  72. */
  73. public function testPersistentConnectionsToSameNodeDoNotShareResourceUsingDifferentPersistentID()
  74. {
  75. if ($this->isHHVM()) {
  76. $this->markTestSkipped('This test does not currently work on HHVM.');
  77. }
  78. $connection1 = $this->createConnectionWithParams(array('persistent' => 'conn1'));
  79. $connection2 = $this->createConnectionWithParams(array('persistent' => 'conn2'));
  80. $this->assertPersistentConnection($connection1);
  81. $this->assertPersistentConnection($connection2);
  82. $this->assertNotSame($connection1->getResource(), $connection2->getResource());
  83. }
  84. }