StreamConnectionTest.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. * @requires PHP 5.4
  23. */
  24. public function testPersistentParameterWithFalseLikeValues()
  25. {
  26. $connection1 = $this->createConnectionWithParams(array('persistent' => 0));
  27. $this->assertNonPersistentConnection($connection1);
  28. $connection2 = $this->createConnectionWithParams(array('persistent' => false));
  29. $this->assertNonPersistentConnection($connection2);
  30. $connection3 = $this->createConnectionWithParams(array('persistent' => '0'));
  31. $this->assertNonPersistentConnection($connection3);
  32. $connection4 = $this->createConnectionWithParams(array('persistent' => 'false'));
  33. $this->assertNonPersistentConnection($connection4);
  34. }
  35. /**
  36. * @group connected
  37. * @requires PHP 5.4
  38. */
  39. public function testPersistentParameterWithTrueLikeValues()
  40. {
  41. $connection1 = $this->createConnectionWithParams(array('persistent' => 1));
  42. $this->assertPersistentConnection($connection1);
  43. $connection2 = $this->createConnectionWithParams(array('persistent' => true));
  44. $this->assertPersistentConnection($connection2);
  45. $connection3 = $this->createConnectionWithParams(array('persistent' => '1'));
  46. $this->assertPersistentConnection($connection3);
  47. $connection4 = $this->createConnectionWithParams(array('persistent' => 'true'));
  48. $this->assertPersistentConnection($connection4);
  49. $connection1->disconnect();
  50. }
  51. /**
  52. * @group connected
  53. * @requires PHP 5.4
  54. */
  55. public function testPersistentConnectionsToSameNodeShareResource()
  56. {
  57. $connection1 = $this->createConnectionWithParams(array('persistent' => true));
  58. $connection2 = $this->createConnectionWithParams(array('persistent' => true));
  59. $this->assertPersistentConnection($connection1);
  60. $this->assertPersistentConnection($connection2);
  61. $this->assertSame($connection1->getResource(), $connection2->getResource());
  62. $connection1->disconnect();
  63. }
  64. /**
  65. * @group connected
  66. * @requires PHP 5.4
  67. */
  68. public function testPersistentConnectionsToSameNodeDoNotShareResourceUsingDifferentPersistentID()
  69. {
  70. $connection1 = $this->createConnectionWithParams(array('persistent' => 'conn1'));
  71. $connection2 = $this->createConnectionWithParams(array('persistent' => 'conn2'));
  72. $this->assertPersistentConnection($connection1);
  73. $this->assertPersistentConnection($connection2);
  74. $this->assertNotSame($connection1->getResource(), $connection2->getResource());
  75. }
  76. }