From cc4389767037d237391e069afab205d334825c80 Mon Sep 17 00:00:00 2001 From: Hafiz Muhammad Moaz Date: Mon, 7 Sep 2026 14:49:58 +0500 Subject: [PATCH 1/2] fix: make test suite platform independent (fixes #43) --- tests/CLITest.php | 17 +++++++++++------ tests/ExitCodeTest.php | 8 -------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/tests/CLITest.php b/tests/CLITest.php index ee659e1..b8f4ffc 100644 --- a/tests/CLITest.php +++ b/tests/CLITest.php @@ -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 @@ -76,7 +79,7 @@ public function testLiveLine() : void public function testIsWindows() : void { - self::assertFalse(CLI::isWindows()); + self::assertSame(\DIRECTORY_SEPARATOR === '\\', CLI::isWindows()); } /** @@ -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; } diff --git a/tests/ExitCodeTest.php b/tests/ExitCodeTest.php index fbda99c..50ae435 100644 --- a/tests/ExitCodeTest.php +++ b/tests/ExitCodeTest.php @@ -9,14 +9,6 @@ * file that was distributed with this source code. */ declare(strict_types=1); -/* - * This file is part of Webisters CLI Library. - * - * (c) Hafiz Muhammad Moaz - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ namespace Tests\CLI; use PHPUnit\Framework\TestCase; From 67194f57b155a030e0f1d3e4e7a88bf810df840d Mon Sep 17 00:00:00 2001 From: Hafiz Muhammad Moaz Date: Mon, 7 Sep 2026 14:52:41 +0500 Subject: [PATCH 2/2] style: fix ExitCodeTest header order --- tests/ExitCodeTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/ExitCodeTest.php b/tests/ExitCodeTest.php index 50ae435..fbda99c 100644 --- a/tests/ExitCodeTest.php +++ b/tests/ExitCodeTest.php @@ -9,6 +9,14 @@ * file that was distributed with this source code. */ declare(strict_types=1); +/* + * This file is part of Webisters CLI Library. + * + * (c) Hafiz Muhammad Moaz + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Tests\CLI; use PHPUnit\Framework\TestCase;