3declare(strict_types=1);
 
    7require_once(
"libs/composer/vendor/autoload.php");
 
   10use PHPUnit\Framework\TestCase;
 
   21    protected function setUp(): void
 
   33        $v = $this->f->color(
'#0fff2f');
 
   35        $this->assertEquals(
'#0fff2f', $v->asHex());
 
   36        $this->assertEquals(
'rgb(15, 255, 47)', $v->asRGBString());
 
   37        $this->assertEquals(array(15, 255, 47), $v->asArray());
 
   38        $this->assertEquals(15, $v->r());
 
   39        $this->assertEquals(255, $v->g());
 
   40        $this->assertEquals(47, $v->b());
 
   45        $v = $this->f->color(
'#f0f');
 
   46        $this->assertEquals(
'#ff00ff', $v->asHex());
 
   47        $this->assertEquals(
'rgb(255, 0, 255)', $v->asRGBString());
 
   48        $this->assertEquals(array(255, 0, 255), $v->asArray());
 
   53        $v = $this->f->color(
'f0f');
 
   54        $this->assertEquals(
'#ff00ff', $v->asHex());
 
   55        $this->assertEquals(
'rgb(255, 0, 255)', $v->asRGBString());
 
   56        $this->assertEquals(array(255, 0, 255), $v->asArray());
 
   61        $v = $this->f->color(array(15,255,47));
 
   62        $this->assertEquals(
'#0fff2f', $v->asHex());
 
   63        $this->assertEquals(
'rgb(15, 255, 47)', $v->asRGBString());
 
   64        $this->assertEquals(array(15, 255, 47), $v->asArray());
 
   70            $v = $this->f->color(array(-1,0,0));
 
   71            $this->assertFalse(
"This should not happen.");
 
   72        } 
catch (InvalidArgumentException 
$e) {
 
   73            $this->assertTrue(
true);
 
   80            $v = $this->f->color(array(256,0,0));
 
   81            $this->assertFalse(
"This should not happen.");
 
   82        } 
catch (InvalidArgumentException 
$e) {
 
   83            $this->assertTrue(
true);
 
   90            $v = $this->f->color(array(1,1,
'123'));
 
   91            $this->assertFalse(
"This should not happen.");
 
   92        } 
catch (InvalidArgumentException 
$e) {
 
   93            $this->assertTrue(
true);
 
  100            $v = $this->f->color(array());
 
  101            $this->assertFalse(
"This should not happen.");
 
  102        } 
catch (InvalidArgumentException 
$e) {
 
  103            $this->assertTrue(
true);
 
  110            $v = $this->f->color(
'1234');
 
  111            $this->assertFalse(
"This should not happen.");
 
  112        } 
catch (InvalidArgumentException 
$e) {
 
  113            $this->assertTrue(
true);
 
  120            $v = $this->f->color(
'#ff');
 
  121            $this->assertFalse(
"This should not happen.");
 
  122        } 
catch (InvalidArgumentException 
$e) {
 
  123            $this->assertTrue(
true);
 
  130            $v = $this->f->color(
'#gg0000');
 
  131            $this->assertFalse(
"This should not happen.");
 
  132        } 
catch (InvalidArgumentException 
$e) {
 
  133            $this->assertTrue(
true);
 
  139        $v = $this->f->color(
'#6541f4');
 
  140        $this->assertEquals(
true, $v->isDark());
 
  145        $v = $this->f->color(
'#c1f441');
 
  146        $this->assertEquals(
false, $v->isDark());
 
Tests working with color data object.