Esempio n. 1
0
 /**
  * @testdox A color hex hash can be set and received in the correct and valid rgba format
  *
  * @covers Mautic\CoreBundle\Helper\EncryptionHelper::toRgba
  */
 public function testThatColorHexAreConvertedToRgbaCorrectly()
 {
     $colors = ['#ccc' => 'rgba(204,204,204,%g)', '#fff' => 'rgba(255,255,255,%g)', '#000' => 'rgba(0,0,0,%g)', '#333333' => 'rgba(51,51,51,%g)', '#369' => 'rgba(51,102,153,%g)', '#f8Ac30' => 'rgba(248,172,48,%g)'];
     foreach ($colors as $hex => $rgba) {
         $helper = new ColorHelper($hex);
         $randA = round(mt_rand(0, mt_getrandmax() - 1) / mt_getrandmax(), 2);
         $this->assertEquals(sprintf($rgba, $randA), $helper->toRgba($randA, $randA));
     }
 }