RedisCasterTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\VarDumper\Tests\Caster;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
  13. /**
  14. * @author Nicolas Grekas <p@tchwork.com>
  15. * @requires extension redis
  16. */
  17. class RedisCasterTest extends TestCase
  18. {
  19. use VarDumperTestTrait;
  20. public function testNotConnected()
  21. {
  22. $redis = new \Redis();
  23. $xCast = <<<'EODUMP'
  24. Redis {
  25. isConnected: false
  26. }
  27. EODUMP;
  28. $this->assertDumpMatchesFormat($xCast, $redis);
  29. }
  30. public function testConnected()
  31. {
  32. $redis = new \Redis();
  33. if (!@$redis->connect('127.0.0.1')) {
  34. $e = error_get_last();
  35. self::markTestSkipped($e['message']);
  36. }
  37. $xCast = <<<'EODUMP'
  38. Redis {%A
  39. isConnected: true
  40. host: "127.0.0.1"
  41. port: 6379
  42. auth: null
  43. mode: ATOMIC
  44. dbNum: 0
  45. timeout: 0.0
  46. lastError: null
  47. persistentId: null
  48. options: {
  49. TCP_KEEPALIVE: 0
  50. READ_TIMEOUT: 0.0
  51. COMPRESSION: NONE
  52. SERIALIZER: NONE
  53. PREFIX: null
  54. SCAN: NORETRY
  55. }
  56. }
  57. EODUMP;
  58. $this->assertDumpMatchesFormat($xCast, $redis);
  59. }
  60. }