/** * 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; }
/** * @testdox The random color is within borders and not 0, 0, 0 * * @covers Mautic\CoreBundle\Helper\EncryptionHelper::buildRandomColor * @covers Mautic\CoreBundle\Helper\EncryptionHelper::getColorArray */ public function testThatRandomColorIsWithinBorders() { $helper = new ColorHelper(); $helper->buildRandomColor(); $rgb = $helper->getColorArray(); $this->assertGreaterThan(0, $rgb[0]); $this->assertGreaterThan(0, $rgb[1]); $this->assertGreaterThan(0, $rgb[2]); $this->assertLessThanOrEqual(256, $rgb[0]); $this->assertLessThanOrEqual(256, $rgb[1]); $this->assertLessThanOrEqual(256, $rgb[2]); }