vendor/bin/phpunit on Windows with piped output gives 8 failures out of 75 tests (PHP 8.4.19, main 2c0159f):
1) CLITest::testWrite 5) CLITest::testStyle
2) CLITest::testLiveLine 6) CLITest::testStyleWithInvalidColor
3) CLITest::testIsWindows 7) CLITest::testStyleWithInvalidBackground
4) CLITest::testClear 8) CLITest::testStyleWithInvalidFormat
Setting WT_SESSION=1 (which makes supportsAnsi() return true) brings it down to 2 failures, which isolates the causes:
- Six of them assume ANSI is always on.
CLI::style() returns the text unchanged when supportsAnsi() is false, so both the escape sequence assertions and the three ValueError assertions fail. Tests should force a known state with CLI::setAnsi(true) in setUp() rather than inherit the terminal's.
testIsWindows() asserts assertFalse(CLI::isWindows()), which can only pass on non Windows. It should assert against DIRECTORY_SEPARATOR instead.
getTerminalWidth() shells out to tput cols, which does not exist on Windows.
testWrite and others hardcode \n where the code writes PHP_EOL, so they fail on CRLF platforms.
CI only runs ubuntu, where supportsAnsi() returns true unconditionally, which is why this is green there and red for anyone developing on Windows.
Unrelated but in the same area: tests/ExitCodeTest.php:1-19 has the license header duplicated, with declare(strict_types=1); sandwiched between the two copies.
vendor/bin/phpuniton Windows with piped output gives 8 failures out of 75 tests (PHP 8.4.19, main 2c0159f):Setting
WT_SESSION=1(which makessupportsAnsi()return true) brings it down to 2 failures, which isolates the causes:CLI::style()returns the text unchanged whensupportsAnsi()is false, so both the escape sequence assertions and the threeValueErrorassertions fail. Tests should force a known state withCLI::setAnsi(true)insetUp()rather than inherit the terminal's.testIsWindows()assertsassertFalse(CLI::isWindows()), which can only pass on non Windows. It should assert againstDIRECTORY_SEPARATORinstead.getTerminalWidth()shells out totput cols, which does not exist on Windows.testWriteand others hardcode\nwhere the code writesPHP_EOL, so they fail on CRLF platforms.CI only runs ubuntu, where
supportsAnsi()returns true unconditionally, which is why this is green there and red for anyone developing on Windows.Unrelated but in the same area:
tests/ExitCodeTest.php:1-19has the license header duplicated, withdeclare(strict_types=1);sandwiched between the two copies.