ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSystemStyleIconColorSetTest Class Reference
+ Inheritance diagram for ilSystemStyleIconColorSetTest:
+ Collaboration diagram for ilSystemStyleIconColorSetTest:

Public Member Functions

 testConstruct ()
 
 testAddColor ()
 
 testGetInvalidId ()
 
 testDoesColorExist ()
 
 testMergeColorSet ()
 
 testGetColorsSortedAsArray ()
 
 testAsArray ()
 
 testAsString ()
 

Detailed Description

Definition at line 25 of file ilSystemStyleIconColorSetTest.php.

Member Function Documentation

◆ testAddColor()

ilSystemStyleIconColorSetTest::testAddColor ( )

Definition at line 34 of file ilSystemStyleIconColorSetTest.php.

34  : void
35  {
36  $color1 = new ilSystemStyleIconColor('id1', 'name', 'FF0000', 'description');
37  $color2 = new ilSystemStyleIconColor('id2', 'name', 'FF0000', 'description');
38 
39  $set = new ilSystemStyleIconColorSet();
40 
41  $this->assertEquals([], $set->getColors());
42 
43  $set->addColor($color1);
44 
45  $this->assertCount(1, $set->getColors());
46  $this->assertEquals($color1, $set->getColorById('id1'));
47 
48  $set->addColor($color2);
49  $this->assertCount(2, $set->getColors());
50  $this->assertEquals($color1, $set->getColorById('id1'));
51  $this->assertEquals($color2, $set->getColorById('id2'));
52 
53  $set->addColor($color2);
54  $this->assertCount(2, $set->getColors());
55  $this->assertEquals($color1, $set->getColorById('id1'));
56  $this->assertEquals($color2, $set->getColorById('id2'));
57  }

◆ testAsArray()

ilSystemStyleIconColorSetTest::testAsArray ( )

Definition at line 140 of file ilSystemStyleIconColorSetTest.php.

140  : void
141  {
142  $white = new ilSystemStyleIconColor('id1', 'name', 'FFFFFF', 'description');
143  $black = new ilSystemStyleIconColor('id2', 'name', '000000', 'description');
144  $grey = new ilSystemStyleIconColor('id3', 'name', 'AAAAAA', 'description');
145 
146  $red = new ilSystemStyleIconColor('id4', 'name', 'FF0000', 'description');
147  $green = new ilSystemStyleIconColor('id5', 'name', '00FF00', 'description');
148  $blue = new ilSystemStyleIconColor('id6', 'name', '0000FF', 'description');
149 
150  $as_array = ['id1','id2','id3','id4','id5','id6'];
151 
152  $set1 = new ilSystemStyleIconColorSet();
153 
154  $set1->addColor($white);
155  $set1->addColor($black);
156  $set1->addColor($grey);
157  $set1->addColor($red);
158  $set1->addColor($green);
159  $set1->addColor($blue);
160 
161  $this->assertEquals($as_array, $set1->asArray());
162  }

◆ testAsString()

ilSystemStyleIconColorSetTest::testAsString ( )

Definition at line 164 of file ilSystemStyleIconColorSetTest.php.

164  : void
165  {
166  $white = new ilSystemStyleIconColor('id1', 'name', 'FFFFFF', 'description');
167  $black = new ilSystemStyleIconColor('id2', 'name', '000000', 'description');
168  $grey = new ilSystemStyleIconColor('id3', 'name', 'AAAAAA', 'description');
169 
170  $red = new ilSystemStyleIconColor('id4', 'name', 'FF0000', 'description');
171  $green = new ilSystemStyleIconColor('id5', 'name', '00FF00', 'description');
172  $blue = new ilSystemStyleIconColor('id6', 'name', '0000FF', 'description');
173 
174  $as_string = 'id1; id2; id3; id4; id5; id6; ';
175 
176  $set1 = new ilSystemStyleIconColorSet();
177 
178  $set1->addColor($white);
179  $set1->addColor($black);
180  $set1->addColor($grey);
181  $set1->addColor($red);
182  $set1->addColor($green);
183  $set1->addColor($blue);
184 
185  $this->assertEquals($as_string, $set1->asString());
186  }

◆ testConstruct()

ilSystemStyleIconColorSetTest::testConstruct ( )

Definition at line 27 of file ilSystemStyleIconColorSetTest.php.

27  : void
28  {
29  $set = new ilSystemStyleIconColorSet();
30 
31  $this->assertEquals([], $set->getColors());
32  }

◆ testDoesColorExist()

ilSystemStyleIconColorSetTest::testDoesColorExist ( )

Definition at line 73 of file ilSystemStyleIconColorSetTest.php.

73  : void
74  {
75  $color1 = new ilSystemStyleIconColor('id1', 'name', 'FF0000', 'description');
76  $set = new ilSystemStyleIconColorSet();
77  $set->addColor($color1);
78 
79  $this->assertTrue($set->doesColorExist('id1'));
80  $this->assertFalse($set->doesColorExist('otherId'));
81  $this->assertFalse($set->doesColorExist(''));
82  }

◆ testGetColorsSortedAsArray()

ilSystemStyleIconColorSetTest::testGetColorsSortedAsArray ( )

Definition at line 111 of file ilSystemStyleIconColorSetTest.php.

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

111  : void
112  {
113  $white = new ilSystemStyleIconColor('id1', 'name', 'FFFFFF', 'description');
114  $black = new ilSystemStyleIconColor('id2', 'name', '000000', 'description');
115  $grey = new ilSystemStyleIconColor('id3', 'name', 'AAAAAA', 'description');
116 
117  $red = new ilSystemStyleIconColor('id4', 'name', 'FF0000', 'description');
118  $green = new ilSystemStyleIconColor('id5', 'name', '00FF00', 'description');
119  $blue = new ilSystemStyleIconColor('id6', 'name', '0000FF', 'description');
120 
121  $ordered_array = [
122  ilSystemStyleIconColor::GREY => [$black,$grey,$white],
123  ilSystemStyleIconColor::RED => [$red],
124  ilSystemStyleIconColor::GREEN => [$green],
126  ];
127 
128  $set1 = new ilSystemStyleIconColorSet();
129 
130  $set1->addColor($white);
131  $set1->addColor($black);
132  $set1->addColor($grey);
133  $set1->addColor($red);
134  $set1->addColor($green);
135  $set1->addColor($blue);
136 
137  $this->assertEquals($ordered_array, $set1->getColorsSortedAsArray());
138  }

◆ testGetInvalidId()

ilSystemStyleIconColorSetTest::testGetInvalidId ( )

Definition at line 59 of file ilSystemStyleIconColorSetTest.php.

References Vendor\Package\$e, and ilSystemStyleException\INVALID_ID.

59  : void
60  {
61  $color1 = new ilSystemStyleIconColor('id1', 'name', 'FF0000', 'description');
62  $set = new ilSystemStyleIconColorSet();
63  $set->addColor($color1);
64 
65  try {
66  $set->getColorById('idXY');
67  $this->fail();
68  } catch (ilSystemStyleException $e) {
69  $this->assertEquals(ilSystemStyleException::INVALID_ID, $e->getCode());
70  }
71  }

◆ testMergeColorSet()

ilSystemStyleIconColorSetTest::testMergeColorSet ( )

Definition at line 84 of file ilSystemStyleIconColorSetTest.php.

84  : void
85  {
86  $color1 = new ilSystemStyleIconColor('id1', 'name', 'FF0000', 'description');
87  $color2 = new ilSystemStyleIconColor('id2', 'name', 'FF0000', 'description');
88  $color3 = new ilSystemStyleIconColor('id3', 'name', 'FF0000', 'description');
89 
90  $set1 = new ilSystemStyleIconColorSet();
91  $set2 = new ilSystemStyleIconColorSet();
92 
93  $set1->addColor($color1);
94  $set1->addColor($color2);
95 
96  $set2->addColor($color2);
97  $set2->addColor($color3);
98 
99  $set1->mergeColorSet($set2);
100 
101  $this->assertCount(3, $set1->getColors());
102  $this->assertEquals($color1, $set1->getColorById('id1'));
103  $this->assertEquals($color2, $set1->getColorById('id2'));
104  $this->assertEquals($color3, $set1->getColorById('id3'));
105 
106  $this->assertCount(2, $set2->getColors());
107  $this->assertEquals($color2, $set2->getColorById('id2'));
108  $this->assertEquals($color3, $set2->getColorById('id3'));
109  }

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