mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 06:37:55 +08:00 
			
		
		
		
	Fix #17884: Fix 0 values in console Table rendered as empty string
This commit is contained in:
		@ -14,6 +14,7 @@ Yii Framework 2 Change Log
 | 
				
			|||||||
- Bug #17863: `\yii\helpers\BaseInflector::slug()` doesn't work with an empty string as a replacement argument (haruatari)
 | 
					- Bug #17863: `\yii\helpers\BaseInflector::slug()` doesn't work with an empty string as a replacement argument (haruatari)
 | 
				
			||||||
- Bug #17881: `yii\db\Query::queryScalar()` wasn’t reverting the `select`, `orderBy`, `limit`, and `offset` params if an exception occurred (brandonkelly)
 | 
					- Bug #17881: `yii\db\Query::queryScalar()` wasn’t reverting the `select`, `orderBy`, `limit`, and `offset` params if an exception occurred (brandonkelly)
 | 
				
			||||||
- Bug #17875: Use `move_uploaded_file()` function instead of `copy()` and `unlink()` for saving uploaded files in case of POST request (sup-ham)
 | 
					- Bug #17875: Use `move_uploaded_file()` function instead of `copy()` and `unlink()` for saving uploaded files in case of POST request (sup-ham)
 | 
				
			||||||
 | 
					- Bug #17884: Fix 0 values in console Table rendered as empty string (mikehaertl)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
2.0.32 January 21, 2020
 | 
					2.0.32 January 21, 2020
 | 
				
			||||||
 | 
				
			|||||||
@ -133,7 +133,7 @@ class Table extends Widget
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->rows = array_map(function($row) {
 | 
					        $this->rows = array_map(function($row) {
 | 
				
			||||||
            return array_map(function($value) {
 | 
					            return array_map(function($value) {
 | 
				
			||||||
                return $value ?: ' ';
 | 
					                return empty($value) && !is_numeric($value) ? ' ' : $value;
 | 
				
			||||||
            }, array_values($row));
 | 
					            }, array_values($row));
 | 
				
			||||||
        }, $rows);
 | 
					        }, $rows);
 | 
				
			||||||
        return $this;
 | 
					        return $this;
 | 
				
			||||||
 | 
				
			|||||||
@ -286,7 +286,7 @@ EXPECTED;
 | 
				
			|||||||
        );
 | 
					        );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function testEmptyTableCell()
 | 
					    public function testEmptyAndZeroTableCell()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $table = new Table();
 | 
					        $table = new Table();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -294,13 +294,23 @@ EXPECTED;
 | 
				
			|||||||
╔═══════╤═══════╗
 | 
					╔═══════╤═══════╗
 | 
				
			||||||
║ test1 │ test2 ║
 | 
					║ test1 │ test2 ║
 | 
				
			||||||
╟───────┼───────╢
 | 
					╟───────┼───────╢
 | 
				
			||||||
║ test  │       ║
 | 
					║ 0     │       ║
 | 
				
			||||||
 | 
					╟───────┼───────╢
 | 
				
			||||||
 | 
					║ 0.0   │       ║
 | 
				
			||||||
╚═══════╧═══════╝
 | 
					╚═══════╧═══════╝
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EXPECTED;
 | 
					EXPECTED;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->assertEqualsWithoutLE($expected, $table->setHeaders(['test1', 'test2'])
 | 
					        $this->assertEqualsWithoutLE(
 | 
				
			||||||
            ->setRows([['test', []]])->setScreenWidth(200)->run()
 | 
					            $expected,
 | 
				
			||||||
 | 
					            $table
 | 
				
			||||||
 | 
					                ->setHeaders(['test1', 'test2'])
 | 
				
			||||||
 | 
					                ->setRows([
 | 
				
			||||||
 | 
					                    ['0', []],
 | 
				
			||||||
 | 
					                    ['0.0', []],
 | 
				
			||||||
 | 
					                ])
 | 
				
			||||||
 | 
					                ->setScreenWidth(200)
 | 
				
			||||||
 | 
					                ->run()
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user