JsonDescriptorTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\Descriptor;
  11. use Symfony\Component\Console\Descriptor\JsonDescriptor;
  12. class JsonDescriptorTest extends AbstractDescriptorTestCase
  13. {
  14. protected function getDescriptor()
  15. {
  16. return new JsonDescriptor();
  17. }
  18. protected static function getFormat()
  19. {
  20. return 'json';
  21. }
  22. protected function normalizeOutput($output)
  23. {
  24. return array_map([$this, 'normalizeOutputRecursively'], json_decode($output, true));
  25. }
  26. private function normalizeOutputRecursively($output)
  27. {
  28. if (\is_array($output)) {
  29. return array_map([$this, 'normalizeOutputRecursively'], $output);
  30. }
  31. if (null === $output) {
  32. return null;
  33. }
  34. return parent::normalizeOutput($output);
  35. }
  36. }