ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSystemStyleIconColorSetTest Class Reference
+ Inheritance diagram for ilSystemStyleIconColorSetTest:
+ Collaboration diagram for ilSystemStyleIconColorSetTest:

Public Member Functions

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

Detailed Description

Member Function Documentation

◆ testAddColor()

ilSystemStyleIconColorSetTest::testAddColor ( )

Definition at line 23 of file ilSystemStyleIconColorSetTest.php.

24  {
25  $color1 = new ilSystemStyleIconColor("id1", "name", "FF0000", "description");
26  $color2 = new ilSystemStyleIconColor("id2", "name", "FF0000", "description");
27 
28  $set = new ilSystemStyleIconColorSet();
29 
30  $this->assertEquals([], $set->getColors());
31 
32  $set->addColor($color1);
33 
34  $this->assertEquals(1, count($set->getColors()));
35  $this->assertEquals($color1, $set->getColorById("id1"));
36 
37  $set->addColor($color2);
38  $this->assertEquals(2, count($set->getColors()));
39  $this->assertEquals($color1, $set->getColorById("id1"));
40  $this->assertEquals($color2, $set->getColorById("id2"));
41 
42  $set->addColor($color2);
43  $this->assertEquals(2, count($set->getColors()));
44  $this->assertEquals($color1, $set->getColorById("id1"));
45  $this->assertEquals($color2, $set->getColorById("id2"));
46  }

◆ testAsArray()

ilSystemStyleIconColorSetTest::testAsArray ( )

Definition at line 129 of file ilSystemStyleIconColorSetTest.php.

References $black, $blue, $green, $red, and $white.

130  {
131  $white = new ilSystemStyleIconColor("id1", "name", "FFFFFF", "description");
132  $black = new ilSystemStyleIconColor("id2", "name", "000000", "description");
133  $grey = new ilSystemStyleIconColor("id3", "name", "AAAAAA", "description");
134 
135  $red = new ilSystemStyleIconColor("id4", "name", "FF0000", "description");
136  $green = new ilSystemStyleIconColor("id5", "name", "00FF00", "description");
137  $blue = new ilSystemStyleIconColor("id6", "name", "0000FF", "description");
138 
139  $as_array = ["id1","id2","id3","id4","id5","id6"];
140 
141  $set1 = new ilSystemStyleIconColorSet();
142 
143  $set1->addColor($white);
144  $set1->addColor($black);
145  $set1->addColor($grey);
146  $set1->addColor($red);
147  $set1->addColor($green);
148  $set1->addColor($blue);
149 
150  $this->assertEquals($as_array, $set1->asArray());
151  }
$blue
Definition: example_030.php:81
$red
Definition: example_030.php:80
$green
Definition: example_030.php:83
$white
Definition: example_030.php:84
$black
Definition: example_030.php:85

◆ testAsString()

ilSystemStyleIconColorSetTest::testAsString ( )

Definition at line 153 of file ilSystemStyleIconColorSetTest.php.

References $black, $blue, $green, $red, and $white.

154  {
155  $white = new ilSystemStyleIconColor("id1", "name", "FFFFFF", "description");
156  $black = new ilSystemStyleIconColor("id2", "name", "000000", "description");
157  $grey = new ilSystemStyleIconColor("id3", "name", "AAAAAA", "description");
158 
159  $red = new ilSystemStyleIconColor("id4", "name", "FF0000", "description");
160  $green = new ilSystemStyleIconColor("id5", "name", "00FF00", "description");
161  $blue = new ilSystemStyleIconColor("id6", "name", "0000FF", "description");
162 
163  $as_string = "id1; id2; id3; id4; id5; id6; ";
164 
165  $set1 = new ilSystemStyleIconColorSet();
166 
167  $set1->addColor($white);
168  $set1->addColor($black);
169  $set1->addColor($grey);
170  $set1->addColor($red);
171  $set1->addColor($green);
172  $set1->addColor($blue);
173 
174  $this->assertEquals($as_string, $set1->asString());
175  }
$blue
Definition: example_030.php:81
$red
Definition: example_030.php:80
$green
Definition: example_030.php:83
$white
Definition: example_030.php:84
$black
Definition: example_030.php:85

◆ testConstruct()

ilSystemStyleIconColorSetTest::testConstruct ( )

Definition at line 16 of file ilSystemStyleIconColorSetTest.php.

17  {
18  $set = new ilSystemStyleIconColorSet();
19 
20  $this->assertEquals([], $set->getColors());
21  }

◆ testDoesColorExist()

ilSystemStyleIconColorSetTest::testDoesColorExist ( )

Definition at line 62 of file ilSystemStyleIconColorSetTest.php.

63  {
64  $color1 = new ilSystemStyleIconColor("id1", "name", "FF0000", "description");
65  $set = new ilSystemStyleIconColorSet();
66  $set->addColor($color1);
67 
68  $this->assertTrue($set->doesColorExist("id1"));
69  $this->assertFalse($set->doesColorExist("otherId"));
70  $this->assertFalse($set->doesColorExist(""));
71  }

◆ testGetColorsSortedAsArray()

ilSystemStyleIconColorSetTest::testGetColorsSortedAsArray ( )

Definition at line 100 of file ilSystemStyleIconColorSetTest.php.

References $black, $blue, $green, $red, $white, ilSystemStyleIconColor\BLUE, ilSystemStyleIconColor\GREEN, ilSystemStyleIconColor\GREY, and ilSystemStyleIconColor\RED.

101  {
102  $white = new ilSystemStyleIconColor("id1", "name", "FFFFFF", "description");
103  $black = new ilSystemStyleIconColor("id2", "name", "000000", "description");
104  $grey = new ilSystemStyleIconColor("id3", "name", "AAAAAA", "description");
105 
106  $red = new ilSystemStyleIconColor("id4", "name", "FF0000", "description");
107  $green = new ilSystemStyleIconColor("id5", "name", "00FF00", "description");
108  $blue = new ilSystemStyleIconColor("id6", "name", "0000FF", "description");
109 
110  $ordered_array = [
115  ];
116 
117  $set1 = new ilSystemStyleIconColorSet();
118 
119  $set1->addColor($white);
120  $set1->addColor($black);
121  $set1->addColor($grey);
122  $set1->addColor($red);
123  $set1->addColor($green);
124  $set1->addColor($blue);
125 
126  $this->assertEquals($ordered_array, $set1->getColorsSortedAsArray());
127  }
$blue
Definition: example_030.php:81
$red
Definition: example_030.php:80
$green
Definition: example_030.php:83
$white
Definition: example_030.php:84
$black
Definition: example_030.php:85

◆ testGetInvalidId()

ilSystemStyleIconColorSetTest::testGetInvalidId ( )

Definition at line 48 of file ilSystemStyleIconColorSetTest.php.

References ilSystemStyleException\INVALID_ID.

49  {
50  $color1 = new ilSystemStyleIconColor("id1", "name", "FF0000", "description");
51  $set = new ilSystemStyleIconColorSet();
52  $set->addColor($color1);
53 
54  try {
55  $set->getColorById("idXY");
56  $this->assertTrue(false);
57  } catch (ilSystemStyleException $e) {
58  $this->assertEquals(ilSystemStyleException::INVALID_ID, $e->getCode());
59  }
60  }
Class for advanced editing exception handling in ILIAS.

◆ testMergeColorSet()

ilSystemStyleIconColorSetTest::testMergeColorSet ( )

Definition at line 73 of file ilSystemStyleIconColorSetTest.php.

74  {
75  $color1 = new ilSystemStyleIconColor("id1", "name", "FF0000", "description");
76  $color2 = new ilSystemStyleIconColor("id2", "name", "FF0000", "description");
77  $color3 = new ilSystemStyleIconColor("id3", "name", "FF0000", "description");
78 
79  $set1 = new ilSystemStyleIconColorSet();
80  $set2 = new ilSystemStyleIconColorSet();
81 
82  $set1->addColor($color1);
83  $set1->addColor($color2);
84 
85  $set2->addColor($color2);
86  $set2->addColor($color3);
87 
88  $set1->mergeColorSet($set2);
89 
90  $this->assertEquals(3, count($set1->getColors()));
91  $this->assertEquals($color1, $set1->getColorById("id1"));
92  $this->assertEquals($color2, $set1->getColorById("id2"));
93  $this->assertEquals($color3, $set1->getColorById("id3"));
94 
95  $this->assertEquals(2, count($set2->getColors()));
96  $this->assertEquals($color2, $set2->getColorById("id2"));
97  $this->assertEquals($color3, $set2->getColorById("id3"));
98  }

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