ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Tests\Setup\Metrics\MetricTest Class Reference
+ Inheritance diagram for ILIAS\Tests\Setup\Metrics\MetricTest:
+ Collaboration diagram for ILIAS\Tests\Setup\Metrics\MetricTest:

Public Member Functions

 testConstructMetric (string $stability, string $type, $value, string $description, bool $success)
 
 testToYAML (M $metric, string $expected)
 
 testIndentation ()
 
 testExtractBySeverity ()
 
 testToArrayWithFlatValues (M $metric, string $expected)
 
 testToArrayWithDeepOne ()
 
 testToArrayWithDeepTwo ()
 
 testToUIReport ()
 

Static Public Member Functions

static metricProvider ()
 
static typedMetricsProvider ()
 

Detailed Description

Definition at line 32 of file MetricTest.php.

Member Function Documentation

◆ metricProvider()

static ILIAS\Tests\Setup\Metrics\MetricTest::metricProvider ( )
static

Definition at line 47 of file MetricTest.php.

47 : array
48 {
53
60
61 $other_metric = new Metrics\Metric($volatile, $bool, true);
62
63 return [
64 "invalid_stability" => ["no_stability", $bool, true, "", false],
65 "invalid_type" => [$config, "no_type", true, "", false],
66
67 "bool" => [$config, $bool, true, "A boolean", true],
68 "counter" => [$stable, $counter, 23, "A counter", true],
69 "gauge1" => [$volatile, $gauge, 42, "A gauge", true],
70 "gauge2" => [$volatile, $gauge, 13.37, "A gauge", true],
71 "timestamp" => [$config, $timestamp, new \DateTimeImmutable(), "A timestamp", true],
72 "text" => [$stable, $text, "some text", "A text", true],
73 "collection" => [$volatile, $collection, ["other" => $other_metric], "A collection", true],
74
75 "no_bool1" => [$config, $bool, 1, "", false],
76 "no_bool2" => [$config, $bool, "foo", "", false],
77 "no_bool3" => [$config, $bool, new \DateTimeImmutable(), "", false],
78 "no_bool4" => [$config, $bool, [], "", false],
79
80 "no_counter1" => [$stable, $counter, false, "", false],
81 "no_counter2" => [$stable, $counter, 3.1, "", false],
82 "no_counter3" => [$stable, $counter, "foo", "", false],
83 "no_counter4" => [$stable, $counter, new \DateTimeImmutable(), "", false],
84 "no_counter5" => [$stable, $counter, [], "", false],
85
86 "no_gauge1" => [$volatile, $gauge, true, "", false],
87 "no_gauge2" => [$volatile, $gauge, "foo", "", false],
88 "no_gauge3" => [$volatile, $gauge, new \DateTimeImmutable(), "", false],
89 "no_gauge4" => [$volatile, $gauge, [], "", false],
90
91 "no_timestamp1" => [$config, $timestamp, false, "", false],
92 "no_timestamp2" => [$config, $timestamp, 1, "", false],
93 "no_timestamp3" => [$config, $timestamp, "foo", "", false],
94 "no_timestamp4" => [$config, $timestamp, [], "", false],
95
96 "no_text1" => [$stable, $text, true, "", false],
97 "no_text2" => [$stable, $text, 1, "", false],
98 "no_text3" => [$stable, $text, new \DateTimeImmutable(), "", false],
99 "no_text4" => [$stable, $text, [], "", false],
100
101 "no_collection1" => [$volatile, $collection, false, "", false],
102 "no_collection2" => [$volatile, $collection, 1, "", false],
103 "no_collection3" => [$volatile, $collection, new \DateTimeImmutable(), "", false],
104 "no_collection4" => [$volatile, $collection, "foo", "", false],
105 "no_collection5" => [$volatile, $collection, ["a"], "", false],
106
107 "mixed_collection" => [$mixed, $collection, [], "", true],
108 "no_mixed_bool" => [$mixed, $bool, true, "", false],
109 "no_mixed_counter" => [$mixed, $counter, 1, "", false],
110 "no_mixed_gauge" => [$mixed, $gauge, 1.0, "", false],
111 "no_mixed_timestamp" => [$mixed, $timestamp, new \DateTimeImmutable(), "", false],
112 "no_mixed_text" => [$mixed, $text, "", "", false],
113 ];
114 }
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:70
const TYPE_BOOL
The type of the metric tells what to expect of the values.
Definition: Metric.php:53
const STABILITY_CONFIG
The stability of a metric tells how often we expect changes in the metric.
Definition: Metric.php:40
$counter

References $counter, $timestamp, ILIAS\Setup\Metrics\Metric\STABILITY_CONFIG, ILIAS\Setup\Metrics\Metric\STABILITY_MIXED, ILIAS\Setup\Metrics\Metric\STABILITY_STABLE, ILIAS\Setup\Metrics\Metric\STABILITY_VOLATILE, ILIAS\Setup\Metrics\Metric\TYPE_BOOL, ILIAS\Setup\Metrics\Metric\TYPE_COLLECTION, ILIAS\Setup\Metrics\Metric\TYPE_COUNTER, ILIAS\Setup\Metrics\Metric\TYPE_GAUGE, ILIAS\Setup\Metrics\Metric\TYPE_TEXT, and ILIAS\Setup\Metrics\Metric\TYPE_TIMESTAMP.

◆ testConstructMetric()

ILIAS\Tests\Setup\Metrics\MetricTest::testConstructMetric ( string  $stability,
string  $type,
  $value,
string  $description,
bool  $success 
)

Definition at line 35 of file MetricTest.php.

35 : void
36 {
37 if (!$success) {
38 $this->expectException(\InvalidArgumentException::class);
39 }
40 $metric = new Metrics\Metric($stability, $type, $value, $description);
41 $this->assertEquals($stability, $metric->getStability());
42 $this->assertEquals($type, $metric->getType());
43 $this->assertEquals($value, $metric->getValue());
44 $this->assertEquals($description, $metric->getDescription());
45 }

◆ testExtractBySeverity()

ILIAS\Tests\Setup\Metrics\MetricTest::testExtractBySeverity ( )

Definition at line 177 of file MetricTest.php.

177 : void
178 {
179 $metrics = new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
180 "a" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
181 "h" => new M(M::STABILITY_CONFIG, M::TYPE_TEXT, "a_h"),
182 "c" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
183 "d" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
184 "e" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_c_d_e"),
185 "f" => new M(M::STABILITY_VOLATILE, M::TYPE_TEXT, "a_c_d_f")
186 ]),
187 "g" => new M(M::STABILITY_CONFIG, M::TYPE_TEXT, "a_c_g")
188 ]),
189 "i" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_i\na_i")
190 ]),
191 "b" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
192 "j" => new M(M::STABILITY_VOLATILE, M::TYPE_TEXT, "b_j")
193 ]),
194 "k" => new M(M::STABILITY_CONFIG, M::TYPE_TEXT, "k")
195 ]);
196
197 $expected_extracted = new M(M::STABILITY_CONFIG, M::TYPE_COLLECTION, [
198 "a" => new M(M::STABILITY_CONFIG, M::TYPE_COLLECTION, [
199 "h" => new M(M::STABILITY_CONFIG, M::TYPE_TEXT, "a_h"),
200 "c" => new M(M::STABILITY_CONFIG, M::TYPE_COLLECTION, [
201 "g" => new M(M::STABILITY_CONFIG, M::TYPE_TEXT, "a_c_g")
202 ]),
203 ]),
204 "k" => new M(M::STABILITY_CONFIG, M::TYPE_TEXT, "k")
205 ]);
206 $expected_rest = new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
207 "a" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
208 "c" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
209 "d" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
210 "e" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_c_d_e"),
211 "f" => new M(M::STABILITY_VOLATILE, M::TYPE_TEXT, "a_c_d_f")
212 ])
213 ]),
214 "i" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_i\na_i")
215 ]),
216 "b" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
217 "j" => new M(M::STABILITY_VOLATILE, M::TYPE_TEXT, "b_j")
218 ])
219 ]);
220
221 list($extracted, $rest) = $metrics->extractByStability(M::STABILITY_CONFIG);
222
223 $this->assertEquals($expected_extracted, $extracted);
224 $this->assertEquals($expected_rest, $rest);
225 }

◆ testIndentation()

ILIAS\Tests\Setup\Metrics\MetricTest::testIndentation ( )

Definition at line 138 of file MetricTest.php.

138 : void
139 {
140 $metrics = new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
141 "a" => new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
142 "h" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_h"),
143 "c" => new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
144 "d" => new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
145 "e" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_c_d_e"),
146 "f" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_c_d_f")
147 ]),
148 "g" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_c_g")
149 ]),
150 "i" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_i\na_i")
151 ]),
152 "b" => new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
153 "j" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "b_j")
154 ]),
155 "k" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "k")
156 ]);
157
158 $expected = <<<METRIC
159a:
160 h: a_h
161 c:
162 d:
163 e: a_c_d_e
164 f: a_c_d_f
165 g: a_c_g
166 i: >
167 a_i
168 a_i
169b:
170 j: b_j
171k: k
172METRIC;
173
174 $this->assertEquals($expected, $metrics->toYAML());
175 }

◆ testToArrayWithDeepOne()

ILIAS\Tests\Setup\Metrics\MetricTest::testToArrayWithDeepOne ( )

Definition at line 233 of file MetricTest.php.

233 : void
234 {
235 $metric = new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
236 "bool_true" => new M(M::STABILITY_STABLE, M::TYPE_BOOL, true)
237 ]);
238
239 $this->assertEquals(["bool_true" => "true"], $metric->toArray());
240 }

◆ testToArrayWithDeepTwo()

ILIAS\Tests\Setup\Metrics\MetricTest::testToArrayWithDeepTwo ( )

Definition at line 242 of file MetricTest.php.

242 : void
243 {
244 $metric = new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
245 "db" => new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
246 "bool_true" => new M(M::STABILITY_STABLE, M::TYPE_BOOL, true)
247 ])
248 ]);
249
250 $this->assertEquals(["db" => ["bool_true" => "true"]], $metric->toArray());
251 }

◆ testToArrayWithFlatValues()

ILIAS\Tests\Setup\Metrics\MetricTest::testToArrayWithFlatValues ( $metric,
string  $expected 
)

Definition at line 228 of file MetricTest.php.

228 : void
229 {
230 $this->assertEquals($expected, $metric->toArray());
231 }

◆ testToUIReport()

ILIAS\Tests\Setup\Metrics\MetricTest::testToUIReport ( )

Definition at line 253 of file MetricTest.php.

253 : void
254 {
255 $factory = $this->createMock(Factory::class);
256 $listing_f = new LF();
257 $panel_f = new PF(
258 $listing_f,
259 new \ILIAS\UI\Implementation\Component\Panel\Secondary\Factory(),
260 );
261 $signal = new SignalGenerator();
262 $legacy_f = $this->createMock(\ILIAS\UI\Implementation\Component\Legacy\Factory::class);
263 $legacy = $legacy_f->content("<pre>string</pre>");
264
265 $legacy_f
266 ->expects($this->once())
267 ->method("content")
268 ->willReturn($legacy);
269
270 $factory
271 ->expects($this->once())
272 ->method("legacy")
273 ->willReturn($legacy_f)
274 ;
275
276 $factory
277 ->expects($this->exactly(2))
278 ->method("panel")
279 ->willReturn($panel_f)
280 ;
281
282 $metric = new M(M::STABILITY_STABLE, M::TYPE_TEXT, "string", "");
283
284 $result = $metric->toUIReport($factory, "Status");
285
286 $this->assertInstanceOf(Report::class, $result);
287 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

◆ testToYAML()

ILIAS\Tests\Setup\Metrics\MetricTest::testToYAML ( $metric,
string  $expected 
)

Definition at line 117 of file MetricTest.php.

117 : void
118 {
119 $this->assertEquals($expected, $metric->toYAML());
120 }

◆ typedMetricsProvider()

static ILIAS\Tests\Setup\Metrics\MetricTest::typedMetricsProvider ( )
static

Definition at line 122 of file MetricTest.php.

122 : array
123 {
124 return [
125 "bool_true" => [new M(M::STABILITY_STABLE, M::TYPE_BOOL, true), "true"],
126 "bool_false" => [new M(M::STABILITY_STABLE, M::TYPE_BOOL, false), "false"],
127 "counter_0" => [new M(M::STABILITY_STABLE, M::TYPE_COUNTER, 0), "0"],
128 "counter_1337" => [new M(M::STABILITY_STABLE, M::TYPE_COUNTER, 1337), "1337"],
129 "gauge_23" => [new M(M::STABILITY_STABLE, M::TYPE_GAUGE, 23), "23"],
130 "gauge_42_0" => [new M(M::STABILITY_STABLE, M::TYPE_GAUGE, 42.0), "42.000"],
131 "gauge_42_001" => [new M(M::STABILITY_STABLE, M::TYPE_GAUGE, 42.001), "42.001"],
132 "timestamp" => [new M(M::STABILITY_STABLE, M::TYPE_TIMESTAMP, new \DateTimeImmutable("1985-05-04T13:37:00+01:00")), "1985-05-04T13:37:00+0100"],
133 "text" => [new M(M::STABILITY_STABLE, M::TYPE_TEXT, "some text"), "some text"],
134 "text_with_nl" => [new M(M::STABILITY_STABLE, M::TYPE_TEXT, "some\ntext"), ">\nsome\ntext"],
135 ];
136 }

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