Browse Source

Fixes #15407

tags/2.0.14
Dmitry Dorogin 7 years ago committed by SilverFire - Dmitry Naumenko
parent
commit
73fddb004e
No known key found for this signature in database
GPG Key ID: 39DD917A92B270A
  1. 1
      framework/CHANGELOG.md
  2. 4
      framework/console/widgets/Table.php
  3. 37
      tests/framework/console/widgets/TableTest.php

1
framework/CHANGELOG.md

@ -24,6 +24,7 @@ Yii Framework 2 Change Log
- Bug #15355: Fixed `yii\db\Query::from()` does not work with `yii\db\Expression` (vladis84, silverfire, samdark)
- Bug #15356: Fixed multiple bugs in `yii\db\Query::getTablesUsedInFrom()` (vladis84, samdark)
- Bug #15380: `FormatConverter::convertDateIcuToPhp()` now converts `a` ICU symbols to `A` (brandonkelly)
- Bug #15407: Fixed rendering rows with associative arrays in `yii\console\widgets\Table` (dmrogin)
- Enh #3087: Added `yii\helpers\BaseHtml::error()` "errorSource" option to be able to customize errors display (yanggs07, developeruz, silverfire)
- Enh #3250: Added support for events partial wildcard matching (klimov-paul)
- Enh #5515: Added default value for `yii\behaviors\BlameableBehavior` for cases when the user is guest (dmirogin)

4
framework/console/widgets/Table.php

@ -117,7 +117,7 @@ class Table extends Widget
*/
public function setHeaders(array $headers)
{
$this->_headers = $headers;
$this->_headers = array_values($headers);
return $this;
}
@ -129,7 +129,7 @@ class Table extends Widget
*/
public function setRows(array $rows)
{
$this->_rows = $rows;
$this->_rows = array_map('array_values', $rows);
return $this;
}

37
tests/framework/console/widgets/TableTest.php

@ -21,7 +21,30 @@ class TableTest extends TestCase
$this->mockApplication();
}
public function testTable()
public function getTableData()
{
return [
[
['test1', 'test2', 'test3'],
[
['testcontent1', 'testcontent2', 'testcontent3'],
['testcontent21', 'testcontent22', 'testcontent23'],
]
],
[
['key1' => 'test1', 'key2' => 'test2', 'key3' => 'test3'],
[
['key1' => 'testcontent1', 'key2' => 'testcontent2', 'key3' => 'testcontent3'],
['key1' => 'testcontent21', 'key2' => 'testcontent22', 'key3' => 'testcontent23'],
]
]
];
}
/**
* @dataProvider getTableData
*/
public function testTable($headers, $rows)
{
$table = new Table();
@ -36,12 +59,12 @@ class TableTest extends TestCase
EXPECTED;
$this->assertEqualsWithoutLE($expected, $table->setHeaders(['test1', 'test2', 'test3'])
->setRows([
['testcontent1', 'testcontent2', 'testcontent3'],
['testcontent21', 'testcontent22', 'testcontent23'],
])->setScreenWidth(200)->run()
);
$tableContent = $table
->setHeaders($headers)
->setRows($rows)
->setScreenWidth(200)
->run();
$this->assertEqualsWithoutLE($expected, $tableContent);
}
public function testTableWithFullwidthChars()

Loading…
Cancel
Save