ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 31 of file HtmlMetadataTest.php.

Member Function Documentation

◆ getMockedTag()

HtmlMetadataTest::getMockedTag ( string  $html)

Definition at line 108 of file HtmlMetadataTest.php.

108 : Tag
109 {
110 return new class ($html) extends Tag {
111 public function __construct(
112 protected string $html
113 ) {
114 }
115
116 public function toHtml(): string
117 {
118 return $this->html;
119 }
120 };
121 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

Referenced by testNestedTagCollection(), and testTagCollection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUp()

HtmlMetadataTest::setUp ( )
protected

Definition at line 35 of file HtmlMetadataTest.php.

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

References factory().

+ Here is the call graph for this function:

◆ testEmptyTagCollection()

HtmlMetadataTest::testEmptyTagCollection ( )

Definition at line 64 of file HtmlMetadataTest.php.

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

References factory().

+ Here is the call graph for this function:

◆ testNestedTagCollection()

HtmlMetadataTest::testNestedTagCollection ( )

Definition at line 72 of file HtmlMetadataTest.php.

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

References factory(), and getMockedTag().

+ Here is the call graph for this function:

◆ testNullTag()

HtmlMetadataTest::testNullTag ( )

Definition at line 40 of file HtmlMetadataTest.php.

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

References factory().

+ Here is the call graph for this function:

◆ testTagCollection()

HtmlMetadataTest::testTagCollection ( )

Definition at line 48 of file HtmlMetadataTest.php.

48 : void
49 {
50 $test_tag_1_html = 'test_tag_1_html';
51 $test_tag_1 = $this->getMockedTag($test_tag_1_html);
52
53 $test_tag_2_html = 'test_tag_2_html';
54 $test_tag_2 = $this->getMockedTag($test_tag_2_html);
55
56 $expected_html = $test_tag_1_html . PHP_EOL . $test_tag_2_html . PHP_EOL;
57
58 $tag_collection = $this->factory->collection([$test_tag_1, $test_tag_2]);
59
60 $this->assertCount(2, iterator_to_array($tag_collection->getTags()));
61 $this->assertEquals($expected_html, $tag_collection->toHtml());
62 }

References factory(), and getMockedTag().

+ Here is the call graph for this function:

◆ testUserDefinedTag()

HtmlMetadataTest::testUserDefinedTag ( )

Definition at line 94 of file HtmlMetadataTest.php.

94 : void
95 {
96 $key = 'expected_key';
97 $val = 'expected_value';
98
99 $user_defined_tag = $this->factory->userDefined($key, $val);
100
101 $this->assertInstanceOf(UserDefined::class, $user_defined_tag);
102 $this->assertEquals(
103 "<meta name=\"$key\" content=\"$val\" />",
104 $user_defined_tag->toHtml()
105 );
106 }

References factory().

+ Here is the call graph for this function:

Field Documentation

◆ $factory

Factory HtmlMetadataTest::$factory
protected

Definition at line 33 of file HtmlMetadataTest.php.


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