JsonDescriptorTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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. use Symfony\Component\Console\Output\BufferedOutput;
  13. class JsonDescriptorTest extends AbstractDescriptorTest
  14. {
  15. protected function getDescriptor()
  16. {
  17. return new JsonDescriptor();
  18. }
  19. protected function getFormat()
  20. {
  21. return 'json';
  22. }
  23. protected function assertDescription($expectedDescription, $describedObject, array $options = [])
  24. {
  25. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  26. $this->getDescriptor()->describe($output, $describedObject, $options + ['raw_output' => true]);
  27. $this->assertEquals(json_decode(trim($expectedDescription), true), json_decode(trim(str_replace(PHP_EOL, "\n", $output->fetch())), true));
  28. }
  29. }