4require_once(
"libs/composer/vendor/autoload.php");
7use PHPUnit\Framework\TestCase;
16 protected function setUp() : void
28 $v = $this->f->color(
'#0fff2f');
30 $this->assertEquals(
'#0fff2f', $v->asHex());
31 $this->assertEquals(
'rgb(15, 255, 47)', $v->asRGBString());
32 $this->assertEquals(array(15, 255, 47), $v->asArray());
33 $this->assertEquals(15, $v->r());
34 $this->assertEquals(255, $v->g());
35 $this->assertEquals(47, $v->b());
40 $v = $this->f->color(
'#f0f');
41 $this->assertEquals(
'#ff00ff', $v->asHex());
42 $this->assertEquals(
'rgb(255, 0, 255)', $v->asRGBString());
43 $this->assertEquals(array(255, 0, 255), $v->asArray());
48 $v = $this->f->color(
'f0f');
49 $this->assertEquals(
'#ff00ff', $v->asHex());
50 $this->assertEquals(
'rgb(255, 0, 255)', $v->asRGBString());
51 $this->assertEquals(array(255, 0, 255), $v->asArray());
56 $v = $this->f->color(array(15,255,47));
57 $this->assertEquals(
'#0fff2f', $v->asHex());
58 $this->assertEquals(
'rgb(15, 255, 47)', $v->asRGBString());
59 $this->assertEquals(array(15, 255, 47), $v->asArray());
65 $v = $this->f->color(array(-1,0,0));
66 $this->assertFalse(
"This should not happen.");
67 }
catch (\InvalidArgumentException
$e) {
68 $this->assertTrue(
true);
75 $v = $this->f->color(array(256,0,0));
76 $this->assertFalse(
"This should not happen.");
77 }
catch (\InvalidArgumentException
$e) {
78 $this->assertTrue(
true);
85 $v = $this->f->color(array(1,1,
'123'));
86 $this->assertFalse(
"This should not happen.");
87 }
catch (\InvalidArgumentException
$e) {
88 $this->assertTrue(
true);
95 $v = $this->f->color(array());
96 $this->assertFalse(
"This should not happen.");
97 }
catch (\InvalidArgumentException
$e) {
98 $this->assertTrue(
true);
105 $v = $this->f->color(
'1234');
106 $this->assertFalse(
"This should not happen.");
107 }
catch (\InvalidArgumentException
$e) {
108 $this->assertTrue(
true);
115 $v = $this->f->color(
'#ff');
116 $this->assertFalse(
"This should not happen.");
117 }
catch (\InvalidArgumentException
$e) {
118 $this->assertTrue(
true);
125 $v = $this->f->color(
'#gg0000');
126 $this->assertFalse(
"This should not happen.");
127 }
catch (\InvalidArgumentException
$e) {
128 $this->assertTrue(
true);
134 $v = $this->f->color(
'#6541f4');
135 $this->assertEquals(
true, $v->isDark());
140 $v = $this->f->color(
'#c1f441');
141 $this->assertEquals(
false, $v->isDark());
An exception for terminatinating execution or to throw for unit testing.
Tests working with color data object.