/** * @testdox A color hex hash can be set and received in the correct and valid hex format * * @covers Mautic\CoreBundle\Helper\EncryptionHelper::setHex * @covers Mautic\CoreBundle\Helper\EncryptionHelper::toHex */ public function testThatColorHexAreConvertedBackToHexCorrectly() { $colors = ['#ccc' => '#cccccc', '#fff' => '#ffffff', '#000' => '#000000', '#333333' => '#333333', '#369' => '#336699', '#f8Ac30' => '#f8ac30']; foreach ($colors as $hex1 => $hex2) { $helper = new ColorHelper(); $helper->setHex($hex1); $this->assertEquals($hex2, $helper->toHex()); } }
/** * Generate unique color for the dataset * * @param integer $datasetId * * @return ColorHelper */ public function configureColorHelper($datasetId) { $colorHelper = new ColorHelper(); if (isset($this->colors[$datasetId])) { $color = $colorHelper->setHex($this->colors[$datasetId]); } else { $color = $colorHelper->buildRandomColor(); } return $color; }