ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ColorTest Class Reference

Tests working with color data object. More...

+ Inheritance diagram for ColorTest:
+ Collaboration diagram for ColorTest:

Public Member Functions

 testFullHexValue ()
 
 testShortHexValue ()
 
 testShortHexValue2 ()
 
 testRBGValue ()
 
 testWrongRBGValue ()
 
 testWrongRBGValue2 ()
 
 testWrongRBGValue3 ()
 
 testWrongRBGValue4 ()
 
 testWrongHexValue ()
 
 testWrongHexValue2 ()
 
 testWrongHexValue4 ()
 
 testDarkness ()
 
 testDarkness2 ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Detailed Description

Tests working with color data object.

Author
Nils Haagen nils..nosp@m.haag.nosp@m.en@co.nosp@m.ncep.nosp@m.ts-an.nosp@m.d-tr.nosp@m.ainin.nosp@m.g.de

Definition at line 13 of file ColorTest.php.

Member Function Documentation

◆ setUp()

ColorTest::setUp ( )
protected

Definition at line 15 of file ColorTest.php.

16  {
17  $this->f = new Data\Factory();
18  }

◆ tearDown()

ColorTest::tearDown ( )
protected

Definition at line 20 of file ColorTest.php.

21  {
22  $this->f = null;
23  }

◆ testDarkness()

ColorTest::testDarkness ( )

Definition at line 131 of file ColorTest.php.

132  {
133  $v = $this->f->color('#6541f4');
134  $this->assertEquals(true, $v->isDark());
135  }

◆ testDarkness2()

ColorTest::testDarkness2 ( )

Definition at line 137 of file ColorTest.php.

138  {
139  $v = $this->f->color('#c1f441');
140  $this->assertEquals(false, $v->isDark());
141  }

◆ testFullHexValue()

ColorTest::testFullHexValue ( )

Definition at line 25 of file ColorTest.php.

26  {
27  $v = $this->f->color('#0fff2f');
28 
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());
35  }

◆ testRBGValue()

ColorTest::testRBGValue ( )

Definition at line 53 of file ColorTest.php.

54  {
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());
59  }

◆ testShortHexValue()

ColorTest::testShortHexValue ( )

Definition at line 37 of file ColorTest.php.

38  {
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());
43  }

◆ testShortHexValue2()

ColorTest::testShortHexValue2 ( )

Definition at line 45 of file ColorTest.php.

46  {
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());
51  }

◆ testWrongHexValue()

ColorTest::testWrongHexValue ( )

Definition at line 101 of file ColorTest.php.

102  {
103  try {
104  $v = $this->f->color('1234');
105  $this->assertFalse("This should not happen.");
106  } catch (\InvalidArgumentException $e) {
107  $this->assertTrue(true);
108  }
109  }

◆ testWrongHexValue2()

ColorTest::testWrongHexValue2 ( )

Definition at line 111 of file ColorTest.php.

112  {
113  try {
114  $v = $this->f->color('#ff');
115  $this->assertFalse("This should not happen.");
116  } catch (\InvalidArgumentException $e) {
117  $this->assertTrue(true);
118  }
119  }

◆ testWrongHexValue4()

ColorTest::testWrongHexValue4 ( )

Definition at line 121 of file ColorTest.php.

122  {
123  try {
124  $v = $this->f->color('#gg0000');
125  $this->assertFalse("This should not happen.");
126  } catch (\InvalidArgumentException $e) {
127  $this->assertTrue(true);
128  }
129  }

◆ testWrongRBGValue()

ColorTest::testWrongRBGValue ( )

Definition at line 61 of file ColorTest.php.

62  {
63  try {
64  $v = $this->f->color(array(-1,0,0));
65  $this->assertFalse("This should not happen.");
66  } catch (\InvalidArgumentException $e) {
67  $this->assertTrue(true);
68  }
69  }

◆ testWrongRBGValue2()

ColorTest::testWrongRBGValue2 ( )

Definition at line 71 of file ColorTest.php.

72  {
73  try {
74  $v = $this->f->color(array(256,0,0));
75  $this->assertFalse("This should not happen.");
76  } catch (\InvalidArgumentException $e) {
77  $this->assertTrue(true);
78  }
79  }

◆ testWrongRBGValue3()

ColorTest::testWrongRBGValue3 ( )

Definition at line 81 of file ColorTest.php.

82  {
83  try {
84  $v = $this->f->color(array(1,1,'123'));
85  $this->assertFalse("This should not happen.");
86  } catch (\InvalidArgumentException $e) {
87  $this->assertTrue(true);
88  }
89  }

◆ testWrongRBGValue4()

ColorTest::testWrongRBGValue4 ( )

Definition at line 91 of file ColorTest.php.

92  {
93  try {
94  $v = $this->f->color(array());
95  $this->assertFalse("This should not happen.");
96  } catch (\InvalidArgumentException $e) {
97  $this->assertTrue(true);
98  }
99  }

The documentation for this class was generated from the following file: