ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
HtmlMetadataTest Class Reference
+ Inheritance diagram for HtmlMetadataTest:
+ Collaboration diagram for HtmlMetadataTest:

Public Member Functions

 testNullTag ()
 
 testTagCollection ()
 
 testEmptyTagCollection ()
 
 testNestedTagCollection ()
 
 testUserDefinedTag ()
 
 getMockedTag (string $html)
 

Protected Member Functions

 setUp ()
 

Protected Attributes

Factory $factory
 

Detailed Description

Author
Thibeau Fuhrer thibe.nosp@m.au@s.nosp@m.r.sol.nosp@m.utio.nosp@m.ns

Definition at line 30 of file HtmlMetadataTest.php.

Member Function Documentation

◆ getMockedTag()

HtmlMetadataTest::getMockedTag ( string  $html)

Definition at line 107 of file HtmlMetadataTest.php.

References ILIAS\MetaData\Repository\Validation\Data\__construct().

Referenced by testNestedTagCollection(), and testTagCollection().

107  : Tag
108  {
109  return new class ($html) extends Tag {
110  public function __construct(
111  protected string $html
112  ) {
113  }
114 
115  public function toHtml(): string
116  {
117  return $this->html;
118  }
119  };
120  }
__construct(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUp()

HtmlMetadataTest::setUp ( )
protected

Definition at line 34 of file HtmlMetadataTest.php.

34  : void
35  {
36  $this->factory = new Factory();
37  }

◆ testEmptyTagCollection()

HtmlMetadataTest::testEmptyTagCollection ( )

Definition at line 63 of file HtmlMetadataTest.php.

63  : void
64  {
65  $tag_collection = $this->factory->collection([]);
66 
67  $this->assertEmpty(iterator_to_array($tag_collection->getTags()));
68  $this->assertEmpty($tag_collection->toHtml());
69  }

◆ testNestedTagCollection()

HtmlMetadataTest::testNestedTagCollection ( )

Definition at line 71 of file HtmlMetadataTest.php.

References getMockedTag().

71  : void
72  {
73  $test_tag_1_html = 'test_tag_1_html';
74  $test_tag_1 = $this->getMockedTag($test_tag_1_html);
75 
76  $test_tag_2_html = 'test_tag_2_html';
77  $test_tag_2 = $this->getMockedTag($test_tag_2_html);
78 
79  $test_tag_3_html = 'test_tag_3_html';
80  $test_tag_3 = $this->getMockedTag($test_tag_3_html);
81 
82  $expected_html = $test_tag_1_html . PHP_EOL . $test_tag_2_html . PHP_EOL . $test_tag_3_html . PHP_EOL;
83 
84  $tag_collection = $this->factory->collection([
85  $this->factory->collection([$test_tag_1, $test_tag_2]),
86  $test_tag_3,
87  ]);
88 
89  $this->assertCount(3, iterator_to_array($tag_collection->getTags()));
90  $this->assertEquals($expected_html, $tag_collection->toHtml());
91  }
getMockedTag(string $html)
+ Here is the call graph for this function:

◆ testNullTag()

HtmlMetadataTest::testNullTag ( )

Definition at line 39 of file HtmlMetadataTest.php.

39  : void
40  {
41  $null_tag = $this->factory->nullTag();
42 
43  $this->assertInstanceOf(NullTag::class, $null_tag);
44  $this->assertEmpty($null_tag->toHtml());
45  }

◆ testTagCollection()

HtmlMetadataTest::testTagCollection ( )

Definition at line 47 of file HtmlMetadataTest.php.

References getMockedTag().

47  : void
48  {
49  $test_tag_1_html = 'test_tag_1_html';
50  $test_tag_1 = $this->getMockedTag($test_tag_1_html);
51 
52  $test_tag_2_html = 'test_tag_2_html';
53  $test_tag_2 = $this->getMockedTag($test_tag_2_html);
54 
55  $expected_html = $test_tag_1_html . PHP_EOL . $test_tag_2_html . PHP_EOL;
56 
57  $tag_collection = $this->factory->collection([$test_tag_1, $test_tag_2]);
58 
59  $this->assertCount(2, iterator_to_array($tag_collection->getTags()));
60  $this->assertEquals($expected_html, $tag_collection->toHtml());
61  }
getMockedTag(string $html)
+ Here is the call graph for this function:

◆ testUserDefinedTag()

HtmlMetadataTest::testUserDefinedTag ( )

Definition at line 93 of file HtmlMetadataTest.php.

References ILIAS\LTI\ToolProvider\$key.

93  : void
94  {
95  $key = 'expected_key';
96  $val = 'expected_value';
97 
98  $user_defined_tag = $this->factory->userDefined($key, $val);
99 
100  $this->assertInstanceOf(UserDefined::class, $user_defined_tag);
101  $this->assertEquals(
102  "<meta name=\"$key\" content=\"$val\" />",
103  $user_defined_tag->toHtml()
104  );
105  }
string $key
Consumer key/client ID value.
Definition: System.php:193

Field Documentation

◆ $factory

Factory HtmlMetadataTest::$factory
protected

Definition at line 32 of file HtmlMetadataTest.php.


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