RedisCasterTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. dbNum: 0
  44. timeout: 0.0
  45. persistentId: null
  46. options: {
  47. READ_TIMEOUT: 0.0
  48. SERIALIZER: NONE
  49. PREFIX: null
  50. SCAN: NORETRY
  51. }
  52. }
  53. EODUMP;
  54. $this->assertDumpMatchesFormat($xCast, $redis);
  55. }
  56. }