Returns the contents of the output buffer.
public fetchOutput ( ) : string | ||
return | string | The output data. |
public function testRenderApplicationJson() { $args = new Args($this->helpCommand->getArgsFormat()); $status = $this->handler->handle($args, $this->io, $this->command); $this->assertStringStartsWith('{"commands":[{"name":"help",', $this->io->fetchOutput()); $this->assertSame(0, $status); }
public function testRenderWithIndentation() { $layout = new BlockLayout(); $layout->add(new Paragraph('HEADING 1'))->add(new Paragraph(self::LOREM_IPSUM))->add(new EmptyLine())->add(new LabeledParagraph('Not Aligned', self::LOREM_IPSUM, 1, false))->add(new EmptyLine())->add(new Paragraph('HEADING 2'))->beginBlock()->add(new LabeledParagraph('Label 1', self::LOREM_IPSUM))->add(new LabeledParagraph('Label 2', self::LOREM_IPSUM))->endBlock()->add(new Paragraph('HEADING 3'))->beginBlock()->add(new LabeledParagraph('Longer Label', self::LOREM_IPSUM))->endBlock(); $layout->render($this->io, 4); $expected = <<<'EOF' HEADING 1 Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt Not Aligned Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt HEADING 2 Label 1 Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt Label 2 Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt HEADING 3 Longer Label Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt EOF; $this->assertSame($expected, $this->io->fetchOutput()); }
/** * testTableRenderer. */ public function testListRenderer() { $renderer = RendererFactory::create('list', $this->io); $renderer->render($this->createResultCollection()); $output = <<<LIST [OK][200] Example - 0.42 LIST; $this->assertInstanceOf(RendererInterface::class, $renderer); $this->assertSame($output, $this->io->fetchOutput()); }
public function testRenderApplicationXml() { $args = new Args($this->helpCommand->getArgsFormat()); $status = $this->handler->handle($args, $this->io, $this->command); $expected = <<<'EOF' <?xml version="1.0" encoding="UTF-8"?> <symfony name="The Application" version="1.2.3"> EOF; $this->assertStringStartsWith($expected, $this->io->fetchOutput()); $this->assertSame(0, $status); }
/** * testCsvRenderer. */ public function testCsvRenderer() { $renderer = RendererFactory::create('csv', $this->io); $renderer->render($this->createResultCollection()); $output = <<<CSV "Global Status","Status Code",Name,"Reponse Time","Http Error Log","Validator Error Log" OK,200,Example,0.42,, CSV; $this->assertInstanceOf(RendererInterface::class, $renderer); $this->assertSame($output, $this->io->fetchOutput()); }
public function testRenderApplicationText() { $args = new Args($this->helpCommand->getArgsFormat()); $status = $this->handler->handle($args, $this->io, $this->command); $expected = <<<'EOF' The Application version 1.2.3 USAGE console EOF; $this->assertStringStartsWith($expected, $this->io->fetchOutput()); $this->assertSame(0, $status); }
public function testSkipIndentationForEmptyLines() { $para = new Paragraph(self::LOREM_IPSUM . "\n\n" . self::LOREM_IPSUM); $para->render($this->io, 6); $expected = <<<'EOF' Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt EOF; $this->assertSame($expected, $this->io->fetchOutput()); }
/** * testTableRenderer. */ public function testTableRenderer() { $renderer = RendererFactory::create('table', $this->io); $renderer->render($this->createResultCollection()); $output = <<<TABLE +--------+--------+---------+----------+----------------+---------------------+ | Global | Status | Name | Response | Http Error Log | Validator Error Log | | Status | Code | | Time | | | +--------+--------+---------+----------+----------------+---------------------+ | OK | 200 | Example | 0.42 | | | +--------+--------+---------+----------+----------------+---------------------+ TABLE; $this->assertInstanceOf(RendererInterface::class, $renderer); $this->assertSame($output, $this->io->fetchOutput()); }
public function testClearOutput() { $io = new BufferedIO(); $io->write('Lorem'); $io->clearOutput(); $io->write('ipsum'); $this->assertSame('ipsum', $io->fetchOutput()); }
public function testHandlePrintsToOutputIfProcessLauncherNotSupported() { $this->processLauncher->expects($this->once())->method('isSupported')->will($this->returnValue(false)); $this->processLauncher->expects($this->never())->method('launchProcess'); $status = $this->handler->handle($this->args, $this->io, $this->command); $this->assertSame("Contents of the-command.txt\n", $this->io->fetchOutput()); $this->assertSame(0, $status); }
public function testRenderWithLabelDistanceWrapsText() { $para = new LabeledParagraph('Label', self::LOREM_IPSUM, 6); $para->render($this->io); $expected = <<<'EOF' Label Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt EOF; $this->assertSame($expected, $this->io->fetchOutput()); }
public function testRenderAllCellsInOneLine() { $grid = new Grid(GridStyle::asciiBorder()); $grid->addCells(array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri')); $grid->render($this->io); $expected = <<<'EOF' +---------------+---------------+-----------------+ | 99921-58-10-7 | Divine Comedy | Dante Alighieri | +---------------+---------------+-----------------+ EOF; $this->assertSame($expected, $this->io->fetchOutput()); }
public function testHelpPrintsTextIfAsciiDocNotFound() { $args = $this->helpCommand->parseArgs(new StringArgs('--help')); $this->processLauncher->expects($this->any())->method('isSupported')->will($this->returnValue(true)); $this->executableFinder->expects($this->never())->method('find'); $this->processLauncher->expects($this->never())->method('launchProcess'); $this->handler->setApplicationPage('foobar'); $status = $this->handler->handle($args, $this->io, $this->command); $expected = <<<'EOF' The Application version 1.2.3 USAGE the-app EOF; $this->assertStringStartsWith($expected, $this->io->fetchOutput()); $this->assertSame(0, $status); }
public function testRenderOptionCommandWithPreferredLongName() { $config = ApplicationConfig::create()->setName('test-bin')->beginCommand('command')->beginOptionCommand('add', 'a')->setDescription('Description of "add"')->setPreferLongName()->end()->end(); $application = new ConsoleApplication($config); $help = new CommandHelp($application->getCommand('command')); $help->render($this->io); $expected = <<<'EOF' USAGE test-bin command or: test-bin command --add COMMANDS --add (-a) Description of "add" EOF; $this->assertSame($expected, $this->io->fetchOutput()); }
public function testRenderFormattedCells() { $table = new Table(TableStyle::asciiBorder()); $table->setHeaderRow(array('ISBN', 'Title', 'Author')); $table->addRows(array(array('<b>99921-58-10-7</b>', 'Divine Comedy', 'Dante Alighieri'), array('<b>9971-5-0210-0</b>', 'A Tale of Two Cities', 'Charles Dickens'), array('<b>960-425-059-0</b>', 'The Lord of the Rings', 'J. R. R. Tolkien'), array('<b>80-902734-1-6</b>', 'And Then There Were None', 'Agatha Christie'))); $table->render($this->io); $expected = <<<'EOF' +---------------+--------------------------+------------------+ | ISBN | Title | Author | +---------------+--------------------------+------------------+ | 99921-58-10-7 | Divine Comedy | Dante Alighieri | | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | | 80-902734-1-6 | And Then There Were None | Agatha Christie | +---------------+--------------------------+------------------+ EOF; $this->assertSame($expected, $this->io->fetchOutput()); }
public function testRenderDescription() { $config = ApplicationConfig::create()->setHelp('The help'); $application = new ConsoleApplication($config); $help = new ApplicationHelp($application); $help->render($this->io); $expected = <<<'EOF' Console Tool USAGE console <command> [<arg1>] ... [<argN>] ARGUMENTS <command> The command to execute <arg> The arguments of the command DESCRIPTION The help EOF; $this->assertSame($expected, $this->io->fetchOutput()); }
public function testRenderIgnoresIndentation() { $line = new EmptyLine(); $line->render($this->io, 10); $this->assertSame("\n", $this->io->fetchOutput()); }