diff --git a/Helper/Table.php b/Helper/Table.php index cf714873f..bbe502e36 100644 --- a/Helper/Table.php +++ b/Helper/Table.php @@ -411,7 +411,7 @@ public function render() if ($isHeader && !$isHeaderSeparatorRendered) { $this->renderRowSeparator( - $isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM, + self::SEPARATOR_TOP, $hasTitle ? $this->headerTitle : null, $hasTitle ? $this->style->getHeaderTitleFormat() : null ); @@ -421,7 +421,7 @@ public function render() if ($isFirstRow) { $this->renderRowSeparator( - $isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM, + $horizontal ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM, $hasTitle ? $this->headerTitle : null, $hasTitle ? $this->style->getHeaderTitleFormat() : null ); diff --git a/Tests/ApplicationTest.php b/Tests/ApplicationTest.php index 229297c65..8726b6f76 100644 --- a/Tests/ApplicationTest.php +++ b/Tests/ApplicationTest.php @@ -1573,7 +1573,7 @@ public function testRunWithErrorAndDispatcher() $tester = new ApplicationTester($application); $tester->run(['command' => 'dym']); - $this->assertStringContainsString('before.dym.error.after.', $tester->getDisplay(), 'The PHP Error did not dispached events'); + $this->assertStringContainsString('before.dym.error.after.', $tester->getDisplay(), 'The PHP error did not dispatch events'); } public function testRunDispatchesAllEventsWithError() @@ -1590,7 +1590,7 @@ public function testRunDispatchesAllEventsWithError() $tester = new ApplicationTester($application); $tester->run(['command' => 'dym']); - $this->assertStringContainsString('before.dym.error.after.', $tester->getDisplay(), 'The PHP Error did not dispached events'); + $this->assertStringContainsString('before.dym.error.after.', $tester->getDisplay(), 'The PHP error did not dispatch events'); } public function testRunWithErrorFailingStatusCode() diff --git a/Tests/Helper/TableTest.php b/Tests/Helper/TableTest.php index 9cd5dcc5f..350482a86 100644 --- a/Tests/Helper/TableTest.php +++ b/Tests/Helper/TableTest.php @@ -1017,15 +1017,16 @@ public function testColumnStyle() public function testThrowsWhenTheCellInAnArray() { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('A cell must be a TableCell, a scalar or an object implementing "__toString()", "array" given.'); - $table = new Table($output = $this->getOutputStream()); + $table = new Table($this->getOutputStream()); $table ->setHeaders(['ISBN', 'Title', 'Author', 'Price']) ->setRows([ ['99921-58-10-7', [], 'Dante Alighieri', '9.95'], ]); + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('A cell must be a TableCell, a scalar or an object implementing "__toString()", "array" given.'); + $table->render(); } @@ -1997,4 +1998,63 @@ public function testWithHyperlinkAndMaxWidth() $this->assertSame($expected, $this->getOutputContent($output)); } + + public function testGithubIssue52101HorizontalTrue() + { + $tableStyle = (new TableStyle()) + ->setHorizontalBorderChars('─') + ->setVerticalBorderChars('│') + ->setCrossingChars('┼', '┌', '┬', '┐', '┤', '┘', '┴', '└', '├') + ; + + $table = (new Table($output = $this->getOutputStream())) + ->setStyle($tableStyle) + ->setHeaderTitle('Title') + ->setHeaders(['Hello', 'World']) + ->setRows([[1, 2], [3, 4]]) + ->setHorizontal(true) + ; + $table->render(); + + $this->assertSame(<<