Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 217274b

Browse files
ReenExefabpot
authored andcommitted
Console table cleanup
1 parent 77b5fc4 commit 217274b

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/Symfony/Component/Console/Helper/Table.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,7 @@ public function setColumnStyle($columnIndex, $name)
151151
{
152152
$columnIndex = intval($columnIndex);
153153

154-
if ($name instanceof TableStyle) {
155-
$this->columnStyles[$columnIndex] = $name;
156-
} elseif (isset(self::$styles[$name])) {
157-
$this->columnStyles[$columnIndex] = self::$styles[$name];
158-
} else {
159-
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
160-
}
154+
$this->columnStyles[$columnIndex] = $this->resolveStyle($name);
161155

162156
return $this;
163157
}

src/Symfony/Component/Console/Tests/Helper/TableTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,25 @@ public function testGetStyleDefinition()
650650
Table::getStyleDefinition('absent');
651651
}
652652

653+
/**
654+
* @expectedException \Symfony\Component\Console\Exception\InvalidArgumentException
655+
* @expectedExceptionMessage Style "absent" is not defined.
656+
*/
657+
public function testIsNotDefinedStyleException()
658+
{
659+
$table = new Table($this->getOutputStream());
660+
$table->setStyle('absent');
661+
}
662+
663+
/**
664+
* @expectedException \Symfony\Component\Console\Exception\InvalidArgumentException
665+
* @expectedExceptionMessage Style "absent" is not defined.
666+
*/
667+
public function testGetStyleDefinition()
668+
{
669+
Table::getStyleDefinition('absent');
670+
}
671+
653672
protected function getOutputStream()
654673
{
655674
return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, false);

0 commit comments

Comments
 (0)