Skip to content

Commit

Permalink
minor #38866 [Console] Test degraded true colors (freezy-sk)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fabpot committed Oct 29, 2020
2 parents 01951b0 + 000a909 commit f372360
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Tests/ColorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,20 @@ public function testTrueColors()
$color = new Color('#ffffff', '#000000');
$this->assertSame("\033[38;2;255;255;255;48;2;0;0;0m \033[39;49m", $color->apply(' '));
}

public function testDegradedTrueColors()
{
$colorterm = getenv('COLORTERM');
putenv('COLORTERM=');

try {
$color = new Color('#f00', '#ff0');
$this->assertSame("\033[31;43m \033[39;49m", $color->apply(' '));

$color = new Color('#c0392b', '#f1c40f');
$this->assertSame("\033[31;43m \033[39;49m", $color->apply(' '));
} finally {
putenv('COLORTERM='.$colorterm);
}
}
}

0 comments on commit f372360

Please sign in to comment.