10000 [Console] [SymfonyStyle] Replace long word wrapping test to directly test output by ogizanagi · Pull Request #18896 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] [SymfonyStyle] Replace long word wrapping test to directly test output #18896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Console] [SymfonyStyle] Replace long word wrapping test to directly …
…test output
  • Loading branch information
ogizanagi committed May 29, 2016
commit b78fff417b249bf8e8bea34f0591864dab1d3eaa
Original file line number Diff line number Diff line change
@@ -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);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

§ [CUSTOM] Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophatto
§ peristeralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon

16 changes: 0 additions & 16 deletions src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,6 @@ public function inputCommandToOutputFilesProvider()

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), ' § '));
}
}

/**
Expand Down
0