4 * Class CRM_Utils_ColorTest
7 class CRM_Utils_ColorTest
extends CiviUnitTestCase
{
10 * @dataProvider contrastExamples
12 public function testGetContrast($background, $text) {
13 $this->assertEquals($text, CRM_Utils_Color
::getContrast($background));
16 public function contrastExamples() {
24 ['# 394ba0', 'white'],
25 [' #D54799', 'white'],
30 * @dataProvider rgbExamples
32 public function testGetRgb($color, $expectedRGB, $expectedHex) {
33 $rgb = CRM_Utils_Color
::getRgb($color);
34 $this->assertEquals($expectedRGB, $rgb);
35 $this->assertEquals($expectedHex, CRM_Utils_Color
::rgbToHex($rgb));
38 public function rgbExamples() {
40 ['#fff', [255, 255, 255], '#ffffff'],
41 ['white', [255, 255, 255], '#ffffff'],
42 ['#000000', [0, 0, 0], '#000000'],
43 [' black', [0, 0, 0], '#000000'],
44 [' #111 ', [17, 17, 17], '#111111'],
45 [' fffc99 ', [255, 252, 153], '#fffc99'],
46 ['blue', [0, 0, 255], '#0000ff'],
47 ['Green', [0, 128, 0], '#008000'],
48 ['rgb(12, 0, 123)', [12, 0, 123], '#0c007b'],
49 [' rgb ( 123, 0, 12 ) !important', [123, 0, 12], '#7b000c'],