DumperTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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\Console\Tests\Helper;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Console\Helper\Dumper;
  13. use Symfony\Component\Console\Output\OutputInterface;
  14. use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
  15. class DumperTest extends TestCase
  16. {
  17. use VarDumperTestTrait;
  18. public static function setUpBeforeClass()
  19. {
  20. putenv('DUMP_LIGHT_ARRAY=1');
  21. putenv('DUMP_COMMA_SEPARATOR=1');
  22. }
  23. public static function tearDownAfterClass()
  24. {
  25. putenv('DUMP_LIGHT_ARRAY');
  26. putenv('DUMP_COMMA_SEPARATOR');
  27. }
  28. /**
  29. * @dataProvider provideVariables
  30. */
  31. public function testInvoke($variable)
  32. {
  33. $dumper = new Dumper($this->getMockBuilder(OutputInterface::class)->getMock());
  34. $this->assertDumpMatchesFormat($dumper($variable), $variable);
  35. }
  36. public function provideVariables()
  37. {
  38. return [
  39. [null],
  40. [true],
  41. [false],
  42. [1],
  43. [-1.5],
  44. ['string'],
  45. [[1, '2']],
  46. [new \stdClass()],
  47. ];
  48. }
  49. }