Merge pull request #14833 from seamuslee001/ids_ip_logging_improvements
[civicrm-core.git] / tests / phpunit / CRM / Utils / ColorTest.php
1 <?php
2
3 /**
4 * Class CRM_Utils_ColorTest
5 * @group headless
6 */
7 class CRM_Utils_ColorTest extends CiviUnitTestCase {
8
9 /**
10 * @dataProvider contrastExamples
11 */
12 public function testGetContrast($background, $text) {
13 $this->assertEquals($text, CRM_Utils_Color::getContrast($background));
14 }
15
16 public function contrastExamples() {
17 return [
18 ['ef4444', 'white'],
19 ['FAA31B', 'black'],
20 ['FFF000', 'black'],
21 [' 82c341', 'black'],
22 ['#009F75', 'white'],
23 ['#88C6eD', 'black'],
24 ['# 394ba0', 'white'],
25 [' #D54799', 'white'],
26 ];
27 }
28
29 /**
30 * @dataProvider rgbExamples
31 */
32 public function testGetRgb($hex, $rgb) {
33 $this->assertEquals($rgb, CRM_Utils_Color::getRgb($hex));
34 }
35
36 public function rgbExamples() {
37 return [
38 ['#fff', [255, 255, 255]],
39 ['#000000', [0, 0, 0]],
40 ['#111', [17, 17, 17]],
41 [' fffc99 ', [255, 252, 153]],
42 ];
43 }
44
45 }