[Console] [SymfonyStyle] Replace long word wrapping test to directly test output
This commit is contained in:
parent
a842b97087
commit
b78fff417b
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
|
||||||
|
|
||||||
|
//Ensure long words are properly wrapped in blocks
|
||||||
|
return function (InputInterface $input, OutputInterface $output) {
|
||||||
|
$word = 'Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon';
|
||||||
|
$sfStyle = new SymfonyStyleWithForcedLineLength($input, $output);
|
||||||
|
$sfStyle->block($word, 'CUSTOM', 'fg=white;bg=blue', ' § ', false);
|
||||||
|
};
|
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
§ [CUSTOM] Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophatto
|
||||||
|
§ peristeralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon
|
||||||
|
|
@ -54,22 +54,6 @@ class SymfonyStyleTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
return array_map(null, glob($baseDir.'/command/command_*.php'), glob($baseDir.'/output/output_*.txt'));
|
return array_map(null, glob($baseDir.'/command/command_*.php'), glob($baseDir.'/output/output_*.txt'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLongWordsBlockWrapping()
|
|
||||||
{
|
|
||||||
$word = 'Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygovgollhjvhvljfezefeqifzeiqgiqzhrsdgihqzridghqridghqirshdghdghieridgheirhsdgehrsdvhqrsidhqshdgihrsidvqhneriqsdvjzergetsrfhgrstsfhsetsfhesrhdgtesfhbzrtfbrztvetbsdfbrsdfbrn';
|
|
||||||
$wordLength = strlen($word);
|
|
||||||
$maxLineLength = SymfonyStyle::MAX_LINE_LENGTH - 3;
|
|
||||||
|
|
||||||
$this->command->setCode(function (InputInterface $input, OutputInterface $output) use ($word) {
|
|
||||||
$sfStyle = new SymfonyStyleWithForcedLineLength($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), ' § '));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user