Skip to content

Commit

Permalink
Merge branch '6.3' into 6.4
Browse files Browse the repository at this point in the history
* 6.3:
  [Console] Fix horizontal table top border is incorrectly rendered
  [Tests] Streamline
  [Uid] Fix UuidV7 collisions within the same ms
  [Validator] updated Romanian translation
  • Loading branch information
nicolas-grekas committed Oct 31, 2023
2 parents d9c21b1 + 0d14a9f commit 858c7b5
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Helper/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,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
);
Expand All @@ -433,7 +433,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
);
Expand Down
4 changes: 2 additions & 2 deletions Tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,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()
Expand All @@ -1622,7 +1622,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()
Expand Down
66 changes: 63 additions & 3 deletions Tests/Helper/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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(<<<TABLE
┌──── Title ┬───┐
│ Hello │ 1 │ 3 │
│ World │ 2 │ 4 │
└───────┴───┴───┘
TABLE
,
$this->getOutputContent($output)
);
}

public function testGithubIssue52101HorizontalFalse()
{
$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(false)
;
$table->render();

$this->assertSame(<<<TABLE
┌──── Title ────┐
│ Hello │ World │
├───────┼───────┤
│ 1 │ 2 │
│ 3 │ 4 │
└───────┴───────┘
TABLE,
$this->getOutputContent($output)
);
}
}

0 comments on commit 858c7b5

Please sign in to comment.