[Console] Test degraded true colors

This commit is contained in:
freezy 2020-10-28 15:16:02 +01:00 committed by Fabien Potencier
parent abcc0b8bd3
commit a26dc0931b

View File

@ -40,4 +40,20 @@ class ColorTest extends TestCase
$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);
}
}
}