ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 14 of file ColorTest.php.

Member Function Documentation

◆ setUp()

ColorTest::setUp ( )
protected

Definition at line 16 of file ColorTest.php.

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

◆ tearDown()

ColorTest::tearDown ( )
protected

Definition at line 21 of file ColorTest.php.

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

◆ testDarkness()

ColorTest::testDarkness ( )

Definition at line 132 of file ColorTest.php.

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

◆ testDarkness2()

ColorTest::testDarkness2 ( )

Definition at line 138 of file ColorTest.php.

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

◆ testFullHexValue()

ColorTest::testFullHexValue ( )

Definition at line 26 of file ColorTest.php.

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

◆ testRBGValue()

ColorTest::testRBGValue ( )

Definition at line 54 of file ColorTest.php.

55  {
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());
60  }

◆ testShortHexValue()

ColorTest::testShortHexValue ( )

Definition at line 38 of file ColorTest.php.

39  {
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());
44  }

◆ testShortHexValue2()

ColorTest::testShortHexValue2 ( )

Definition at line 46 of file ColorTest.php.

47  {
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());
52  }

◆ testWrongHexValue()

ColorTest::testWrongHexValue ( )

Definition at line 102 of file ColorTest.php.

References Vendor\Package\$e.

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

◆ testWrongHexValue2()

ColorTest::testWrongHexValue2 ( )

Definition at line 112 of file ColorTest.php.

References Vendor\Package\$e.

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

◆ testWrongHexValue4()

ColorTest::testWrongHexValue4 ( )

Definition at line 122 of file ColorTest.php.

References Vendor\Package\$e.

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

◆ testWrongRBGValue()

ColorTest::testWrongRBGValue ( )

Definition at line 62 of file ColorTest.php.

References Vendor\Package\$e.

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

◆ testWrongRBGValue2()

ColorTest::testWrongRBGValue2 ( )

Definition at line 72 of file ColorTest.php.

References Vendor\Package\$e.

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

◆ testWrongRBGValue3()

ColorTest::testWrongRBGValue3 ( )

Definition at line 82 of file ColorTest.php.

References Vendor\Package\$e.

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

◆ testWrongRBGValue4()

ColorTest::testWrongRBGValue4 ( )

Definition at line 92 of file ColorTest.php.

References Vendor\Package\$e.

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

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