ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 ()
 

Private Attributes

Data Factory $f
 

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 31 of file ColorTest.php.

Member Function Documentation

◆ setUp()

ColorTest::setUp ( )
protected

Definition at line 35 of file ColorTest.php.

35  : void
36  {
37  $this->f = new Data\Factory();
38  }

◆ tearDown()

ColorTest::tearDown ( )
protected

Definition at line 40 of file ColorTest.php.

References null.

40  : void
41  {
42  $this->f = null;
43  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ testDarkness()

ColorTest::testDarkness ( )

Definition at line 151 of file ColorTest.php.

151  : void
152  {
153  $v = $this->f->color('#6541f4');
154  $this->assertEquals(true, $v->isDark());
155  }

◆ testDarkness2()

ColorTest::testDarkness2 ( )

Definition at line 157 of file ColorTest.php.

157  : void
158  {
159  $v = $this->f->color('#c1f441');
160  $this->assertEquals(false, $v->isDark());
161  }

◆ testFullHexValue()

ColorTest::testFullHexValue ( )

Definition at line 45 of file ColorTest.php.

45  : void
46  {
47  $v = $this->f->color('#0fff2f');
48 
49  $this->assertEquals('#0fff2f', $v->asHex());
50  $this->assertEquals('rgb(15, 255, 47)', $v->asRGBString());
51  $this->assertEquals(array(15, 255, 47), $v->asArray());
52  $this->assertEquals(15, $v->r());
53  $this->assertEquals(255, $v->g());
54  $this->assertEquals(47, $v->b());
55  }

◆ testRBGValue()

ColorTest::testRBGValue ( )

Definition at line 73 of file ColorTest.php.

73  : void
74  {
75  $v = $this->f->color(array(15,255,47));
76  $this->assertEquals('#0fff2f', $v->asHex());
77  $this->assertEquals('rgb(15, 255, 47)', $v->asRGBString());
78  $this->assertEquals(array(15, 255, 47), $v->asArray());
79  }

◆ testShortHexValue()

ColorTest::testShortHexValue ( )

Definition at line 57 of file ColorTest.php.

57  : void
58  {
59  $v = $this->f->color('#f0f');
60  $this->assertEquals('#ff00ff', $v->asHex());
61  $this->assertEquals('rgb(255, 0, 255)', $v->asRGBString());
62  $this->assertEquals(array(255, 0, 255), $v->asArray());
63  }

◆ testShortHexValue2()

ColorTest::testShortHexValue2 ( )

Definition at line 65 of file ColorTest.php.

65  : void
66  {
67  $v = $this->f->color('f0f');
68  $this->assertEquals('#ff00ff', $v->asHex());
69  $this->assertEquals('rgb(255, 0, 255)', $v->asRGBString());
70  $this->assertEquals(array(255, 0, 255), $v->asArray());
71  }

◆ testWrongHexValue()

ColorTest::testWrongHexValue ( )

Definition at line 121 of file ColorTest.php.

References Vendor\Package\$e.

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

◆ testWrongHexValue2()

ColorTest::testWrongHexValue2 ( )

Definition at line 131 of file ColorTest.php.

References Vendor\Package\$e.

131  : void
132  {
133  try {
134  $v = $this->f->color('#ff');
135  $this->assertFalse("This should not happen.");
136  } catch (InvalidArgumentException $e) {
137  $this->assertTrue(true);
138  }
139  }

◆ testWrongHexValue4()

ColorTest::testWrongHexValue4 ( )

Definition at line 141 of file ColorTest.php.

References Vendor\Package\$e.

141  : void
142  {
143  try {
144  $v = $this->f->color('#gg0000');
145  $this->assertFalse("This should not happen.");
146  } catch (InvalidArgumentException $e) {
147  $this->assertTrue(true);
148  }
149  }

◆ testWrongRBGValue()

ColorTest::testWrongRBGValue ( )

Definition at line 81 of file ColorTest.php.

References Vendor\Package\$e.

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

◆ testWrongRBGValue2()

ColorTest::testWrongRBGValue2 ( )

Definition at line 91 of file ColorTest.php.

References Vendor\Package\$e.

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

◆ testWrongRBGValue3()

ColorTest::testWrongRBGValue3 ( )

Definition at line 101 of file ColorTest.php.

References Vendor\Package\$e.

101  : void
102  {
103  try {
104  $v = $this->f->color(array(1,1,'123'));
105  $this->assertFalse("This should not happen.");
106  } catch (InvalidArgumentException $e) {
107  $this->assertTrue(true);
108  }
109  }

◆ testWrongRBGValue4()

ColorTest::testWrongRBGValue4 ( )

Definition at line 111 of file ColorTest.php.

References Vendor\Package\$e.

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

Field Documentation

◆ $f

Data Factory ColorTest::$f
private

Definition at line 33 of file ColorTest.php.


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