4require_once(
"libs/composer/vendor/autoload.php");
27 $v = $this->f->color(
'#0fff2f');
29 $this->assertEquals(
'#0fff2f', $v->asHex());
30 $this->assertEquals(
'rgb(15, 255, 47)', $v->asRGBString());
31 $this->assertEquals(array(15, 255, 47), $v->asArray());
32 $this->assertEquals(15, $v->r());
33 $this->assertEquals(255, $v->g());
34 $this->assertEquals(47, $v->b());
39 $v = $this->f->color(
'#f0f');
40 $this->assertEquals(
'#ff00ff', $v->asHex());
41 $this->assertEquals(
'rgb(255, 0, 255)', $v->asRGBString());
42 $this->assertEquals(array(255, 0, 255), $v->asArray());
47 $v = $this->f->color(
'f0f');
48 $this->assertEquals(
'#ff00ff', $v->asHex());
49 $this->assertEquals(
'rgb(255, 0, 255)', $v->asRGBString());
50 $this->assertEquals(array(255, 0, 255), $v->asArray());
55 $v = $this->f->color(array(15,255,47));
56 $this->assertEquals(
'#0fff2f', $v->asHex());
57 $this->assertEquals(
'rgb(15, 255, 47)', $v->asRGBString());
58 $this->assertEquals(array(15, 255, 47), $v->asArray());
64 $v = $this->f->color(array(-1,0,0));
65 $this->assertFalse(
"This should not happen.");
66 }
catch (\InvalidArgumentException $e) {
67 $this->assertTrue(
true);
74 $v = $this->f->color(array(256,0,0));
75 $this->assertFalse(
"This should not happen.");
76 }
catch (\InvalidArgumentException $e) {
77 $this->assertTrue(
true);
84 $v = $this->f->color(array(1,1,
'123'));
85 $this->assertFalse(
"This should not happen.");
86 }
catch (\InvalidArgumentException $e) {
87 $this->assertTrue(
true);
94 $v = $this->f->color(array());
95 $this->assertFalse(
"This should not happen.");
96 }
catch (\InvalidArgumentException $e) {
97 $this->assertTrue(
true);
104 $v = $this->f->color(
'1234');
105 $this->assertFalse(
"This should not happen.");
106 }
catch (\InvalidArgumentException $e) {
107 $this->assertTrue(
true);
114 $v = $this->f->color(
'#ff');
115 $this->assertFalse(
"This should not happen.");
116 }
catch (\InvalidArgumentException $e) {
117 $this->assertTrue(
true);
124 $v = $this->f->color(
'#gg0000');
125 $this->assertFalse(
"This should not happen.");
126 }
catch (\InvalidArgumentException $e) {
127 $this->assertTrue(
true);
133 $v = $this->f->color(
'#6541f4');
134 $this->assertEquals(
true, $v->isDark());
139 $v = $this->f->color(
'#c1f441');
140 $this->assertEquals(
false, $v->isDark());
An exception for terminatinating execution or to throw for unit testing.
Tests working with color data object.