File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
src/Symfony/Component/Console Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ class TableCell
35
35
*/
36
36
public function __construct ($ value = '' , array $ options = array ())
37
37
{
38
+ if (is_numeric ($ value ) && !is_string ($ value )) {
39
+ $ value = (string ) $ value ;
40
+ }
41
+
38
42
$ this ->value = $ value ;
39
43
40
44
// check option names
Original file line number Diff line number Diff line change @@ -509,6 +509,42 @@ public function testRenderMultiByte()
509
509
| 1234 |
510
510
+------+
511
511
512
+ TABLE;
513
+
514
+ $ this ->assertEquals ($ expected , $ this ->getOutputContent ($ output ));
515
+ }
516
+
517
+ public function testTableCellWithNumericIntValue ()
518
+ {
519
+ $ table = new Table ($ output = $ this ->getOutputStream ());
520
+
521
+ $ table ->setRows (array (array (new TableCell (12345 ))));
522
+ $ table ->render ();
523
+
524
+ $ expected =
525
+ <<<'TABLE'
526
+ +-------+
527
+ | 12345 |
528
+ +-------+
529
+
530
+ TABLE;
531
+
532
+ $ this ->assertEquals ($ expected , $ this ->getOutputContent ($ output ));
533
+ }
534
+
535
+ public function testTableCellWithNumericFloatValue ()
536
+ {
537
+ $ table = new Table ($ output = $ this ->getOutputStream ());
538
+
539
+ $ table ->setRows (array (array (new TableCell (12345.01 ))));
540
+ $ table ->render ();
541
+
542
+ $ expected =
543
+ <<<'TABLE'
544
+ +----------+
545
+ | 12345.01 |
546
+ +----------+
547
+
512
548
TABLE;
513
549
514
550
$ this ->assertEquals ($ expected , $ this ->getOutputContent ($ output ));
You can’t perform that action at this time.
0 commit comments