Skip to content

Commit

Permalink
Merge branch '3.2'
Browse files Browse the repository at this point in the history
* 3.2:
  [Console] Fix too strict test
  [FrameworkBundle] Execute the PhpDocExtractor earlier
  [validator] Updated croatian translation
  Update DebugHandlersListener.php
  ignore invalid cookies expires date format
  [Console] SfStyleTest: Remove COLUMN env on tearDown
  [TwigBundle] Fix the name of the cache warming test class
  [Console] Fix TableCell issues with decoration
  Add missing pieces in the upgrade guide to 3.0
  • Loading branch information
nicolas-grekas committed Jan 31, 2017
2 parents 4dab8f5 + dd0f08e commit 1525be8
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Helper/Table.php
Expand Up @@ -599,7 +599,7 @@ private function calculateColumnsWidth($rows)

foreach ($row as $i => $cell) {
if ($cell instanceof TableCell) {
$textLength = strlen($cell);
$textLength = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
if ($textLength > 0) {
$contentColumns = str_split($cell, ceil($textLength / $cell->getColspan()));
foreach ($contentColumns as $position => $content) {
Expand Down
7 changes: 4 additions & 3 deletions Tests/Helper/ProcessHelperTest.php
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Helper\ProcessHelper;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;

class ProcessHelperTest extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -83,9 +84,9 @@ public function provideCommandsAndOutput()
EOT;

$errorMessage = 'An error occurred';
if ('\\' === DIRECTORY_SEPARATOR) {
$successOutputProcessDebug = str_replace("'", '"', $successOutputProcessDebug);
}
$args = new ProcessBuilder(array('php', '-r', 'echo 42;'));
$args = $args->getProcess()->getCommandLine();
$successOutputProcessDebug = str_replace("'php' '-r' 'echo 42;'", $args, $successOutputProcessDebug);

return array(
array('', 'php -r "echo 42;"', StreamOutput::VERBOSITY_VERBOSE, null),
Expand Down
45 changes: 37 additions & 8 deletions Tests/Helper/TableTest.php
Expand Up @@ -35,9 +35,9 @@ protected function tearDown()
/**
* @dataProvider testRenderProvider
*/
public function testRender($headers, $rows, $style, $expected)
public function testRender($headers, $rows, $style, $expected, $decorated = false)
{
$table = new Table($output = $this->getOutputStream());
$table = new Table($output = $this->getOutputStream($decorated));
$table
->setHeaders($headers)
->setRows($rows)
Expand All @@ -51,9 +51,9 @@ public function testRender($headers, $rows, $style, $expected)
/**
* @dataProvider testRenderProvider
*/
public function testRenderAddRows($headers, $rows, $style, $expected)
public function testRenderAddRows($headers, $rows, $style, $expected, $decorated = false)
{
$table = new Table($output = $this->getOutputStream());
$table = new Table($output = $this->getOutputStream($decorated));
$table
->setHeaders($headers)
->addRows($rows)
Expand All @@ -67,9 +67,9 @@ public function testRenderAddRows($headers, $rows, $style, $expected)
/**
* @dataProvider testRenderProvider
*/
public function testRenderAddRowsOneByOne($headers, $rows, $style, $expected)
public function testRenderAddRowsOneByOne($headers, $rows, $style, $expected, $decorated = false)
{
$table = new Table($output = $this->getOutputStream());
$table = new Table($output = $this->getOutputStream($decorated));
$table
->setHeaders($headers)
->setStyle($style)
Expand Down Expand Up @@ -485,6 +485,35 @@ public function testRenderProvider()
TABLE
),
'Coslpan and table cells with comment style' => array(
array(
new TableCell('<comment>Long Title</comment>', array('colspan' => 3)),
),
array(
array(
new TableCell('9971-5-0210-0', array('colspan' => 3)),
),
new TableSeparator(),
array(
'Dante Alighieri',
'J. R. R. Tolkien',
'J. R. R',
),
),
'default',
<<<TABLE
+-----------------+------------------+---------+
|\033[32m \033[39m\033[33mLong Title\033[39m\033[32m \033[39m|
+-----------------+------------------+---------+
| 9971-5-0210-0 |
+-----------------+------------------+---------+
| Dante Alighieri | J. R. R. Tolkien | J. R. R |
+-----------------+------------------+---------+
TABLE
,
true,
),
);
}

Expand Down Expand Up @@ -713,9 +742,9 @@ public function testGetStyleDefinition()
Table::getStyleDefinition('absent');
}

protected function getOutputStream()
protected function getOutputStream($decorated = false)
{
return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, false);
return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, $decorated);
}

protected function getOutputContent(StreamOutput $output)
Expand Down
1 change: 1 addition & 0 deletions Tests/Style/SymfonyStyleTest.php
Expand Up @@ -36,6 +36,7 @@ protected function setUp()

protected function tearDown()
{
putenv('COLUMNS');
$this->command = null;
$this->tester = null;
}
Expand Down

0 comments on commit 1525be8

Please sign in to comment.