Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions tests/CLITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ protected function tearDown() : void
public function testWrite() : void
{
CLI::write('Hello!');
self::assertSame("Hello!\n", Stdout::getContents());
self::assertSame('Hello!' . \PHP_EOL, Stdout::getContents());
Stdout::reset();
CLI::write('Hello!', ForegroundColor::red);
self::assertStringContainsString("\033[0;31mHello!", Stdout::getContents());
Stdout::reset();
CLI::write('Hello!', null, null, 2);
self::assertSame("He\nll\no!\n", Stdout::getContents());
self::assertSame(
'He' . \PHP_EOL . 'll' . \PHP_EOL . 'o!' . \PHP_EOL,
Stdout::getContents()
);
}

public function testBeep() : void
Expand Down Expand Up @@ -76,7 +79,7 @@ public function testLiveLine() : void

public function testIsWindows() : void
{
self::assertFalse(CLI::isWindows());
self::assertSame(\DIRECTORY_SEPARATOR === '\\', CLI::isWindows());
}

/**
Expand All @@ -88,9 +91,11 @@ public function testIsWindows() : void
protected function getTerminalWidth() : int
{
$expected = 80;
$width = (int) \shell_exec('tput cols');
if ($width) {
$expected = $width;
if (\DIRECTORY_SEPARATOR !== '\\') {
$width = (int) \shell_exec('tput cols');
if ($width) {
$expected = $width;
}
}
return $expected;
}
Expand Down
Loading