[Console] Provide a bugfix where an array could be passed
This commit is contained in:
parent
d2a316f0db
commit
de502f7d6c
@ -454,11 +454,16 @@ class Table
|
|||||||
* @param int $line
|
* @param int $line
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
private function fillNextRows(array $rows, $line)
|
private function fillNextRows(array $rows, $line)
|
||||||
{
|
{
|
||||||
$unmergedRows = array();
|
$unmergedRows = array();
|
||||||
foreach ($rows[$line] as $column => $cell) {
|
foreach ($rows[$line] as $column => $cell) {
|
||||||
|
if (null !== $cell && !$cell instanceof TableCell && !is_scalar($cell) && !(is_object($cell) && method_exists($cell, '__toString'))) {
|
||||||
|
throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing __toString, %s given.', gettype($cell)));
|
||||||
|
}
|
||||||
if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
|
if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
|
||||||
$nbLines = $cell->getRowspan() - 1;
|
$nbLines = $cell->getRowspan() - 1;
|
||||||
$lines = array($cell);
|
$lines = array($cell);
|
||||||
|
@ -726,6 +726,22 @@ TABLE;
|
|||||||
$this->assertEquals($expected, $this->getOutputContent($output));
|
$this->assertEquals($expected, $this->getOutputContent($output));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\Console\Exception\InvalidArgumentException
|
||||||
|
* @expectedExceptionMessage A cell must be a TableCell, a scalar or an object implementing __toString, array given.
|
||||||
|
*/
|
||||||
|
public function testThrowsWhenTheCellInAnArray()
|
||||||
|
{
|
||||||
|
$table = new Table($output = $this->getOutputStream());
|
||||||
|
$table
|
||||||
|
->setHeaders(array('ISBN', 'Title', 'Author', 'Price'))
|
||||||
|
->setRows(array(
|
||||||
|
array('99921-58-10-7', array(), 'Dante Alighieri', '9.95'),
|
||||||
|
));
|
||||||
|
|
||||||
|
$table->render();
|
||||||
|
}
|
||||||
|
|
||||||
public function testColumnWith()
|
public function testColumnWith()
|
||||||
{
|
{
|
||||||
$table = new Table($output = $this->getOutputStream());
|
$table = new Table($output = $this->getOutputStream());
|
||||||
|
Reference in New Issue
Block a user