ILIAS  release_8 Revision v8.24
ilSystemStyleIconColorTest Class Reference
+ Inheritance diagram for ilSystemStyleIconColorTest:
+ Collaboration diagram for ilSystemStyleIconColorTest:

Public Member Functions

 testConstruct ()
 
 testSetMethods ()
 
 testLowerCaseColor ()
 
 testInvalidColor1 ()
 
 testInvalidColor2 ()
 
 testValidColor3 ()
 
 testGetDominantAspect ()
 
 testGetPerceivedBrightness ()
 
 testCompareColors ()
 

Detailed Description

Definition at line 25 of file ilSystemStyleIconColorTest.php.

Member Function Documentation

◆ testCompareColors()

ilSystemStyleIconColorTest::testCompareColors ( )

Definition at line 123 of file ilSystemStyleIconColorTest.php.

123 : void
124 {
125 $white = new ilSystemStyleIconColor('id', 'name', 'FFFFFF', 'description');
126 $black = new ilSystemStyleIconColor('id', 'name', '000000', 'description');
127
128 $grey = new ilSystemStyleIconColor('id', 'name', 'AAAAAA', 'description');
129 $red = new ilSystemStyleIconColor('id', 'name', 'FF0000', 'description');
130 $green = new ilSystemStyleIconColor('id', 'name', '00FF00', 'description');
131 $blue = new ilSystemStyleIconColor('id', 'name', '0000FF', 'description');
132
133 $this->assertEquals(1, ilSystemStyleIconColor::compareColors($white, $black));
134 $this->assertEquals(-1, ilSystemStyleIconColor::compareColors($black, $white));
135 $this->assertEquals(0, ilSystemStyleIconColor::compareColors($grey, $grey));
136
137 $this->assertEquals(-1, ilSystemStyleIconColor::compareColors($red, $green));
138 $this->assertEquals(1, ilSystemStyleIconColor::compareColors($red, $blue));
139 $this->assertEquals(-1, ilSystemStyleIconColor::compareColors($blue, $green));
140 }
static compareColors(ilSystemStyleIconColor $color1, ilSystemStyleIconColor $color2)
Used to sort colors according to their brightness.

References ilSystemStyleIconColor\compareColors().

+ Here is the call graph for this function:

◆ testConstruct()

ilSystemStyleIconColorTest::testConstruct ( )

Definition at line 27 of file ilSystemStyleIconColorTest.php.

27 : void
28 {
29 $color = new ilSystemStyleIconColor('id', 'name', 'FF0000', 'description');
30
31 $this->assertEquals('id', $color->getId());
32 $this->assertEquals('name', $color->getName());
33 $this->assertEquals('FF0000', $color->getColor());
34 $this->assertEquals('description', $color->getDescription());
35 }

◆ testGetDominantAspect()

ilSystemStyleIconColorTest::testGetDominantAspect ( )

Definition at line 87 of file ilSystemStyleIconColorTest.php.

87 : void
88 {
89 $white = new ilSystemStyleIconColor('id', 'name', 'FFFFFF', 'description');
90 $black = new ilSystemStyleIconColor('id', 'name', '000000', 'description');
91
92 $grey = new ilSystemStyleIconColor('id', 'name', 'AAAAAA', 'description');
93 $red = new ilSystemStyleIconColor('id', 'name', 'FF0000', 'description');
94 $green = new ilSystemStyleIconColor('id', 'name', '00FF00', 'description');
95 $blue = new ilSystemStyleIconColor('id', 'name', '0000FF', 'description');
96
97 $this->assertEquals(ilSystemStyleIconColor::GREY, $white->getDominatAspect());
98 $this->assertEquals(ilSystemStyleIconColor::GREY, $black->getDominatAspect());
99 $this->assertEquals(ilSystemStyleIconColor::GREY, $grey->getDominatAspect());
100 $this->assertEquals(ilSystemStyleIconColor::RED, $red->getDominatAspect());
101 $this->assertEquals(ilSystemStyleIconColor::GREEN, $green->getDominatAspect());
102 $this->assertEquals(ilSystemStyleIconColor::BLUE, $blue->getDominatAspect());
103 }

References ilSystemStyleIconColor\BLUE, ilSystemStyleIconColor\GREEN, ilSystemStyleIconColor\GREY, and ilSystemStyleIconColor\RED.

◆ testGetPerceivedBrightness()

ilSystemStyleIconColorTest::testGetPerceivedBrightness ( )

Definition at line 105 of file ilSystemStyleIconColorTest.php.

105 : void
106 {
107 $white = new ilSystemStyleIconColor('id', 'name', 'FFFFFF', 'description');
108 $black = new ilSystemStyleIconColor('id', 'name', '000000', 'description');
109
110 $grey = new ilSystemStyleIconColor('id', 'name', 'AAAAAA', 'description');
111 $red = new ilSystemStyleIconColor('id', 'name', 'FF0000', 'description');
112 $green = new ilSystemStyleIconColor('id', 'name', '00FF00', 'description');
113 $blue = new ilSystemStyleIconColor('id', 'name', '0000FF', 'description');
114
115 $this->assertEquals(255, ceil($white->getPerceivedBrightness()));
116 $this->assertEquals(0, ceil($black->getPerceivedBrightness()));
117 $this->assertEquals(170, ceil($grey->getPerceivedBrightness()));
118 $this->assertEquals(140, ceil($red->getPerceivedBrightness()));
119 $this->assertEquals(196, ceil($green->getPerceivedBrightness()));
120 $this->assertEquals(87, ceil($blue->getPerceivedBrightness()));
121 }

◆ testInvalidColor1()

ilSystemStyleIconColorTest::testInvalidColor1 ( )

Definition at line 59 of file ilSystemStyleIconColorTest.php.

59 : void
60 {
61 try {
62 new ilSystemStyleIconColor('id', 'name', '#FF0000', 'description');
63 $this->fail();
65 $this->assertEquals(ilSystemStyleColorException::INVALID_COLOR_EXCEPTION, $e->getCode());
66 }
67 }
Class for advanced editing exception handling in ILIAS.

References Vendor\Package\$e, and ilSystemStyleColorException\INVALID_COLOR_EXCEPTION.

◆ testInvalidColor2()

ilSystemStyleIconColorTest::testInvalidColor2 ( )

Definition at line 68 of file ilSystemStyleIconColorTest.php.

68 : void
69 {
70 try {
71 new ilSystemStyleIconColor('id', 'name', 'ZZ0000', 'description');
72 $this->fail();
74 $this->assertEquals(ilSystemStyleColorException::INVALID_COLOR_EXCEPTION, $e->getCode());
75 }
76 }

References Vendor\Package\$e, and ilSystemStyleColorException\INVALID_COLOR_EXCEPTION.

◆ testLowerCaseColor()

ilSystemStyleIconColorTest::testLowerCaseColor ( )

Definition at line 52 of file ilSystemStyleIconColorTest.php.

52 : void
53 {
54 $color = new ilSystemStyleIconColor('id', 'name', 'abcdef', 'description');
55
56 $this->assertEquals('ABCDEF', $color->getColor());
57 }

◆ testSetMethods()

ilSystemStyleIconColorTest::testSetMethods ( )

Definition at line 37 of file ilSystemStyleIconColorTest.php.

37 : void
38 {
39 $color = new ilSystemStyleIconColor('id', 'name', 'FF0000', 'description');
40
41 $color->setId('idnew');
42 $color->setName('namenew');
43 $color->setColor('EE0000');
44 $color->setDescription('descriptionnew');
45
46 $this->assertEquals('idnew', $color->getId());
47 $this->assertEquals('namenew', $color->getName());
48 $this->assertEquals('EE0000', $color->getColor());
49 $this->assertEquals('descriptionnew', $color->getDescription());
50 }

◆ testValidColor3()

ilSystemStyleIconColorTest::testValidColor3 ( )

Definition at line 77 of file ilSystemStyleIconColorTest.php.

77 : void
78 {
79 try {
80 new ilSystemStyleIconColor('id', 'name', 'F00', 'description');
81 $this->assertTrue(true);
83 $this->fail();
84 }
85 }

References Vendor\Package\$e.


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