24 $this->expectException(\InvalidArgumentException::class);
27 $this->assertEquals($stability, $metric->getStability());
28 $this->assertEquals(
$type, $metric->getType());
29 $this->assertEquals($value, $metric->getValue());
30 $this->assertEquals($description, $metric->getDescription());
50 "invalid_stability" => [
"no_stability", $bool,
true,
"",
false],
51 "invalid_type" => [
$config,
"no_type",
true,
"",
false],
53 "bool" => [
$config, $bool,
true,
"A boolean",
true],
54 "counter" => [$stable, $counter, 23,
"A counter",
true],
55 "gauge1" => [$volatile, $gauge, 42,
"A gauge",
true],
56 "gauge2" => [$volatile, $gauge, 13.37,
"A gauge",
true],
57 "timestamp" => [
$config,
$timestamp, new \DateTimeImmutable(),
"A timestamp",
true],
58 "text" => [$stable, $text,
"some text",
"A text",
true],
59 "collection" => [$volatile, $collection, [
"other" => $other_metric],
"A collection",
true],
61 "no_bool1" => [
$config, $bool, 1,
"",
false],
62 "no_bool2" => [
$config, $bool,
"foo",
"",
false],
63 "no_bool3" => [
$config, $bool, new \DateTimeImmutable(),
"",
false],
64 "no_bool4" => [
$config, $bool, [],
"",
false],
66 "no_counter1" => [$stable, $counter,
false,
"",
false],
67 "no_counter2" => [$stable, $counter, 3.1,
"",
false],
68 "no_counter3" => [$stable, $counter,
"foo",
"",
false],
69 "no_counter4" => [$stable, $counter, new \DateTimeImmutable(),
"",
false],
70 "no_counter5" => [$stable, $counter, [],
"",
false],
72 "no_gauge1" => [$volatile, $gauge,
true,
"",
false],
73 "no_gauge2" => [$volatile, $gauge,
"foo",
"",
false],
74 "no_gauge3" => [$volatile, $gauge, new \DateTimeImmutable(),
"",
false],
75 "no_gauge4" => [$volatile, $gauge, [],
"",
false],
82 "no_text1" => [$stable, $text,
true,
"",
false],
83 "no_text2" => [$stable, $text, 1,
"",
false],
84 "no_text3" => [$stable, $text, new \DateTimeImmutable(),
"",
false],
85 "no_text4" => [$stable, $text, [],
"",
false],
87 "no_collection1" => [$volatile, $collection,
false,
"",
false],
88 "no_collection2" => [$volatile, $collection, 1,
"",
false],
89 "no_collection3" => [$volatile, $collection, new \DateTimeImmutable(),
"",
false],
90 "no_collection4" => [$volatile, $collection,
"foo",
"",
false],
91 "no_collection5" => [$volatile, $collection, [
"a"],
"",
false],
93 "mixed_collection" => [$mixed, $collection, [],
"",
true],
94 "no_mixed_bool" => [$mixed, $bool,
true,
"",
false],
95 "no_mixed_counter" => [$mixed, $counter, 1,
"",
false],
96 "no_mixed_gauge" => [$mixed, $gauge, 1.0,
"",
false],
97 "no_mixed_timestamp" => [$mixed,
$timestamp, new \DateTimeImmutable(),
"",
false],
98 "no_mixed_text" => [$mixed, $text,
"",
"",
false],
107 $this->assertEquals($expected, $metric->toYAML());
113 "bool_true" => [
new M(M::STABILITY_STABLE, M::TYPE_BOOL,
true),
"true"],
114 "bool_false" => [
new M(M::STABILITY_STABLE, M::TYPE_BOOL,
false),
"false"],
115 "counter_0" => [
new M(M::STABILITY_STABLE, M::TYPE_COUNTER, 0),
"0"],
116 "counter_1337" => [
new M(M::STABILITY_STABLE, M::TYPE_COUNTER, 1337),
"1337"],
117 "gauge_23" => [
new M(M::STABILITY_STABLE, M::TYPE_GAUGE, 23),
"23"],
118 "gauge_42_0" => [
new M(M::STABILITY_STABLE, M::TYPE_GAUGE, 42.0),
"42.000"],
119 "gauge_42_001" => [
new M(M::STABILITY_STABLE, M::TYPE_GAUGE, 42.001),
"42.001"],
120 "timestamp" => [
new M(M::STABILITY_STABLE, M::TYPE_TIMESTAMP,
new \
DateTimeImmutable(
"1985-05-04T13:37:00+01:00")),
"1985-05-04T13:37:00+0100"],
121 "text" => [
new M(M::STABILITY_STABLE, M::TYPE_TEXT,
"some text"),
"some text"],
122 "text_with_nl" => [
new M(M::STABILITY_STABLE, M::TYPE_TEXT,
"some\ntext"),
">\nsome\ntext"],
128 $metrics =
new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
129 "a" =>
new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
130 "h" =>
new M(M::STABILITY_STABLE, M::TYPE_TEXT,
"a_h"),
131 "c" =>
new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
132 "d" =>
new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
133 "e" =>
new M(M::STABILITY_STABLE, M::TYPE_TEXT,
"a_c_d_e"),
134 "f" =>
new M(M::STABILITY_STABLE, M::TYPE_TEXT,
"a_c_d_f")
136 "g" =>
new M(M::STABILITY_STABLE, M::TYPE_TEXT,
"a_c_g")
138 "i" =>
new M(M::STABILITY_STABLE, M::TYPE_TEXT,
"a_i\na_i")
140 "b" =>
new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
141 "j" =>
new M(M::STABILITY_STABLE, M::TYPE_TEXT,
"b_j")
143 "k" =>
new M(M::STABILITY_STABLE, M::TYPE_TEXT,
"k")
146 $expected = <<<METRIC
162 $this->assertEquals($expected, $metrics->toYAML());
167 $metrics =
new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
168 "a" =>
new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
169 "h" =>
new M(M::STABILITY_CONFIG, M::TYPE_TEXT,
"a_h"),
170 "c" =>
new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
171 "d" =>
new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
172 "e" =>
new M(M::STABILITY_STABLE, M::TYPE_TEXT,
"a_c_d_e"),
173 "f" =>
new M(M::STABILITY_VOLATILE, M::TYPE_TEXT,
"a_c_d_f")
175 "g" =>
new M(M::STABILITY_CONFIG, M::TYPE_TEXT,
"a_c_g")
177 "i" =>
new M(M::STABILITY_STABLE, M::TYPE_TEXT,
"a_i\na_i")
179 "b" =>
new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
180 "j" =>
new M(M::STABILITY_VOLATILE, M::TYPE_TEXT,
"b_j")
182 "k" =>
new M(M::STABILITY_CONFIG, M::TYPE_TEXT,
"k")
185 $expected_extracted =
new M(M::STABILITY_CONFIG, M::TYPE_COLLECTION, [
186 "a" =>
new M(M::STABILITY_CONFIG, M::TYPE_COLLECTION, [
187 "h" =>
new M(M::STABILITY_CONFIG, M::TYPE_TEXT,
"a_h"),
188 "c" =>
new M(M::STABILITY_CONFIG, M::TYPE_COLLECTION, [
189 "g" =>
new M(M::STABILITY_CONFIG, M::TYPE_TEXT,
"a_c_g")
192 "k" =>
new M(M::STABILITY_CONFIG, M::TYPE_TEXT,
"k")
194 $expected_rest =
new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
195 "a" =>
new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
196 "c" =>
new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
197 "d" =>
new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
198 "e" =>
new M(M::STABILITY_STABLE, M::TYPE_TEXT,
"a_c_d_e"),
199 "f" =>
new M(M::STABILITY_VOLATILE, M::TYPE_TEXT,
"a_c_d_f")
202 "i" =>
new M(M::STABILITY_STABLE, M::TYPE_TEXT,
"a_i\na_i")
204 "b" =>
new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [
205 "j" =>
new M(M::STABILITY_VOLATILE, M::TYPE_TEXT,
"b_j")
209 list($extracted,
$rest) = $metrics->extractByStability(M::STABILITY_CONFIG);
211 $this->assertEquals($expected_extracted, $extracted);
212 $this->assertEquals($expected_rest,
$rest);
220 $this->assertEquals($expected, $metric->toArray());
225 $metric =
new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
226 "bool_true" =>
new M(M::STABILITY_STABLE, M::TYPE_BOOL,
true)
229 $this->assertEquals([
"bool_true" =>
"true"] , $metric->toArray());
234 $metric =
new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
235 "db" =>
new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [
236 "bool_true" =>
new M(M::STABILITY_STABLE, M::TYPE_BOOL,
true)
240 $this->assertEquals([
"db" => [
"bool_true" =>
"true"]] , $metric->toArray());
245 $factory = $this->createMock(Factory::class);
246 $listing_f =
new LF();
247 $panel_f =
new PF($listing_f);
249 $legacy_f = new \ILIAS\UI\Implementation\Component\Legacy\Factory($signal);
250 $legacy = $legacy_f->legacy(
"<pre>string</pre>");
253 ->expects($this->once())
255 ->with(
"<pre>" .
"string" .
"</pre>")
256 ->willReturn($legacy)
260 ->expects($this->exactly(2))
262 ->willReturn($panel_f)
265 $metric =
new M(M::STABILITY_STABLE, M::TYPE_TEXT,
"string",
"");
269 $this->assertInstanceOf(Report::class,
$result);
const TYPE_BOOL
The type of the metric tells what to expect of the values.
testToYAML(M $metric, string $expected)
typedMetricsProvider
A metric is something we can measure about the system.
testToArrayWithFlatValues(M $metric, string $expected)
typedMetricsProvider
testConstructMetric($stability, $type, $value, $description, $success)
metricProvider
foreach($mandatory_scripts as $file) $timestamp
const STABILITY_CONFIG
The stability of a metric tells how often we expect changes in the metric.