Skip to content

Commit f372360

Browse files
committed
minor #38866 [Console] Test degraded true colors (freezy-sk)
This PR was squashed before being merged into the 5.2-dev branch. Discussion ---------- [Console] Test degraded true colors | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#14494 <!-- required for new features --> Testing hidden feature of hex colors degraded to ANSI named colors for terminals without true color support. Commits ------- a26dc0931b [Console] Test degraded true colors
2 parents 01951b0 + 000a909 commit f372360

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Tests/ColorTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,20 @@ public function testTrueColors()
4040
$color = new Color('#ffffff', '#000000');
4141
$this->assertSame("\033[38;2;255;255;255;48;2;0;0;0m \033[39;49m", $color->apply(' '));
4242
}
43+
44+
public function testDegradedTrueColors()
45+
{
46+
$colorterm = getenv('COLORTERM');
47+
putenv('COLORTERM=');
48+
49+
try {
50+
$color = new Color('#f00', '#ff0');
51+
$this->assertSame("\033[31;43m \033[39;49m", $color->apply(' '));
52+
53+
$color = new Color('#c0392b', '#f1c40f');
54+
$this->assertSame("\033[31;43m \033[39;49m", $color->apply(' '));
55+
} finally {
56+
putenv('COLORTERM='.$colorterm);
57+
}
58+
}
4359
}

0 commit comments

Comments
 (0)