3 declare(strict_types=1);
7 require_once(
"libs/composer/vendor/autoload.php");
19 private ?Data\Factory
$f;
21 protected function setUp(): void
23 $this->f =
new Data\Factory();
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.");
73 $this->assertTrue(
true);
80 $v = $this->f->color(array(256,0,0));
81 $this->assertFalse(
"This should not happen.");
83 $this->assertTrue(
true);
90 $v = $this->f->color(array(1,1,
'123'));
91 $this->assertFalse(
"This should not happen.");
93 $this->assertTrue(
true);
100 $v = $this->f->color(array());
101 $this->assertFalse(
"This should not happen.");
103 $this->assertTrue(
true);
110 $v = $this->f->color(
'1234');
111 $this->assertFalse(
"This should not happen.");
113 $this->assertTrue(
true);
120 $v = $this->f->color(
'#ff');
121 $this->assertFalse(
"This should not happen.");
123 $this->assertTrue(
true);
130 $v = $this->f->color(
'#gg0000');
131 $this->assertFalse(
"This should not happen.");
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.