<?php

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use SR\Console\Tests\Style\StyleWithForcedLineLength;
//Ensure questions do not output anything when input is non-interactive
return function (InputInterface $input, OutputInterface $output) {
    $output = new StyleWithForcedLineLength($input, $output);
    $output->title('Title');
    $output->ask('Asking a question', ' answer ', null, function ($result) {
        return trim($result);
    });
    $output->ask('Asking a question 2', ' answer 2 ');
    $output->askHidden('Hidden question');
    $output->choice('Choice question with default', array('choice1', 'choice2'), 'choice1');
    $output->confirm('Confirmation with yes default', true);
    $output->text('Duis aute irure dolor in reprehenderit in voluptate velit esse');
};
<?php

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use SR\Console\Tests\Style\StyleWithForcedLineLength;
//Ensure has single blank line at start when using block element
return function (InputInterface $input, OutputInterface $output) {
    $output = new StyleWithForcedLineLength($input, $output);
    $output->caution('Lorem ipsum dolor sit amet');
};
<?php

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use SR\Console\Tests\Style\StyleWithForcedLineLength;
//Ensure formatting tables when using multiple headers with TableCell
return function (InputInterface $input, OutputInterface $output) {
    $headers = [['ISBN', 'Title', 'Author']];
    $rows = [['978-0521567817', 'De Monarchia', new \Symfony\Component\Console\Helper\TableCell("Dante Alighieri\nspans multiple rows", array('rowspan' => 2))], ['978-0804169127', 'Divine Comedy']];
    $output = new StyleWithForcedLineLength($input, $output);
    $output->table($rows, $headers);
    $output->table($rows);
};
<?php

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use SR\Console\Tests\Style\StyleWithForcedLineLength;
//Ensure has single blank line between blocks
return function (InputInterface $input, OutputInterface $output) {
    $output = new StyleWithForcedLineLength($input, $output);
    $output->warning('Warning');
    $output->caution('Caution');
    $output->error('Error');
    $output->success('Success');
    $output->smallSuccess('Title', 'Success');
    $output->note('Note');
    $output->info('Info');
    $output->block('Custom block', 'CUSTOM', 'fg=white;bg=green', 'X ', true);
    $output->applicationTitle('Name', '0.1.0', null, ['Author' => 'First Last', 'License' => 'MIT']);
    $output->applicationTitle('Name', '0.1.0', 'abcdefg', ['Author' => 'First Last', 'License' => 'MIT']);
    $output->section('Section');
    $output->subSection('Sub-section');
    $output->numberedSection(1, 10, 'PRE', 'Message');
};
<?php

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use SR\Console\Tests\Style\StyleWithForcedLineLength;
//Ensure has single blank line between titles and blocks
return function (InputInterface $input, OutputInterface $output) {
    $output = new StyleWithForcedLineLength($input, $output);
    $output->title('Title');
    $output->warning('Lorem ipsum dolor sit amet');
    $output->title('Title');
};
 public function testLongWordsBlockWrapping()
 {
     $word = 'Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon';
     $wordLength = strlen($word);
     $style = $this->getStyle();
     $inspect = Inspect::this($style);
     $property = $inspect->getProperty('lineLengthMax');
     $maxLineLength = $property->value($style) - 3;
     $this->command->setCode(function (InputInterface $input, OutputInterface $output) use($word) {
         $sfStyle = new StyleWithForcedLineLength($input, $output);
         $sfStyle->block($word, 'CUSTOM', 'fg=white;bg=blue', ' § ', false);
     });
     $this->tester->execute(array(), array('interactive' => false, 'decorated' => false));
     $expectedCount = (int) ceil($wordLength / $maxLineLength) + (int) ($wordLength > $maxLineLength - 5);
     $this->assertSame($expectedCount, substr_count($this->tester->getDisplay(true), ' § '));
 }
<?php

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use SR\Console\Tests\Style\StyleWithForcedLineLength;
//Ensure has proper line ending before outputing a text block like with SymfonyStyle::listing() or SymfonyStyle::text()
return function (InputInterface $input, OutputInterface $output) {
    $output = new StyleWithForcedLineLength($input, $output);
    $output->writeln('Lorem ipsum dolor sit amet');
    $output->listing(array('Lorem ipsum dolor sit amet', 'consectetur adipiscing elit'));
    //Even using write:
    $output->write('Lorem ipsum dolor sit amet');
    $output->listing(array('Lorem ipsum dolor sit amet', 'consectetur adipiscing elit'));
    $output->write('Lorem ipsum dolor sit amet');
    $output->text(array('Lorem ipsum dolor sit amet', 'consectetur adipiscing elit'));
    $output->newLine();
    $output->write('Lorem ipsum dolor sit amet');
    $output->comment(array('Lorem ipsum dolor sit amet', 'consectetur adipiscing elit'), false);
};
<?php

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use SR\Console\Tests\Style\StyleWithForcedLineLength;
//Ensure has single blank line between two titles
return function (InputInterface $input, OutputInterface $output) {
    $output = new StyleWithForcedLineLength($input, $output);
    $output->title('First title');
    $output->title('Second title');
};
<?php

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use SR\Console\Tests\Style\StyleWithForcedLineLength;
//Ensure has single blank line after any text and a title
return function (InputInterface $input, OutputInterface $output) {
    $output = new StyleWithForcedLineLength($input, $output);
    $output->write('Lorem ipsum dolor sit amet');
    $output->title('First title');
    $output->writeln('Lorem ipsum dolor sit amet');
    $output->title('Second title');
    $output->write('Lorem ipsum dolor sit amet');
    $output->write('');
    $output->title('Third title');
    //Ensure edge case by appending empty strings to history:
    $output->write('Lorem ipsum dolor sit amet');
    $output->write(array('', '', ''));
    $output->title('Fourth title');
    //Ensure have manual control over number of blank lines:
    $output->writeln('Lorem ipsum dolor sit amet');
    $output->writeln(array('', ''));
    //Should append an extra blank line
    $output->title('Fifth title');
    $output->writeln('Lorem ipsum dolor sit amet');
    $output->newLine(2);
    //Should append an extra blank line
    $output->title('Fifth title');
};
<?php

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use SR\Console\Tests\Style\StyleWithForcedLineLength;
//Ensure has proper blank line after text block when using a block like with SymfonyStyle::success
return function (InputInterface $input, OutputInterface $output) {
    $output = new StyleWithForcedLineLength($input, $output);
    $output->listing(array('Lorem ipsum dolor sit amet', 'consectetur adipiscing elit'));
    $output->success('Lorem ipsum dolor sit amet');
};
<?php

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use SR\Console\Tests\Style\StyleWithForcedLineLength;
//Ensure formatting tables when using multiple headers with TableCell
return function (InputInterface $input, OutputInterface $output) {
    $output = new StyleWithForcedLineLength($input, $output);
    $output->progressStart(10);
    for ($i = 0; $i < 10; ++$i) {
        $output->progressAdvance(1);
    }
    $output->progressFinish();
};