ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ChainingTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27use PHPUnit\Framework\TestCase;
28
29class ChainingTest extends TestCase
30{
33
34 public function setUp(): void
35 {
36 $this->retriever_a = new class () implements HelpTextRetriever {
37 public function getHelpText(Purpose $purpose, Topic ...$topics): array
38 {
39 return ["a"];
40 }
41 };
42
43 $this->retriever_b = new class () implements HelpTextRetriever {
44 public function getHelpText(Purpose $purpose, Topic ...$topics): array
45 {
46 return ["b"];
47 }
48 };
49 }
50
51 public function testGetHelpTextChaining(): void
52 {
53 $retriever = new Chaining($this->retriever_a, $this->retriever_b);
54
55 $result = $retriever->getHelpText(new Purpose(Purpose::PURPOSE_TOOLTIP));
56
57 $this->assertEquals(["a", "b"], $result);
58 }
59
60 public function testGetHelpTextRemovesDuplicates(): void
61 {
62 $retriever = new Chaining($this->retriever_a, $this->retriever_a);
63
64 $result = $retriever->getHelpText(new Purpose(Purpose::PURPOSE_TOOLTIP));
65
66 $this->assertEquals(["a"], $result);
67 }
68}
A purpose describes the intended use for a certain help text.
Definition: Purpose.php:47
This HelpTextRetriever merges results from various other retrievers (and removes duplicates).
Definition: Chaining.php:31
This is just a class that marks a string as a help topic.
Definition: Topic.php:27
This describes a facility that the UI framework can use to retrieve some help text.