@@ -52,6 +52,43 @@ public function testHtmlAndHEntryLang()
5252 $ this ->assertEquals ('es ' , $ result ['items ' ][0 ]['properties ' ]['html-lang ' ]);
5353 } # end method testHtmlAndHEntryLang()
5454
55+ /**
56+ * Test HTML fragment with only h-entry lang
57+ */
58+ public function testFragmentHEntryLangOnly ()
59+ {
60+ $ input = '<div class="h-entry" lang="en">This test is in English.</div> ' ;
61+ $ parser = new Parser ($ input );
62+ $ result = $ parser ->parse ();
63+
64+ $ this ->assertEquals ('en ' , $ result ['items ' ][0 ]['properties ' ]['html-lang ' ]);
65+ } # end method testFragmentHEntryLangOnly()
66+
67+ /**
68+ * Test HTML fragment with no lang
69+ */
70+ public function testFragmentHEntryNoLang ()
71+ {
72+ $ input = '<div class="h-entry">This test is in English.</div> ' ;
73+ $ parser = new Parser ($ input );
74+ $ result = $ parser ->parse ();
75+
76+ $ this ->assertFalse (isset ($ result ['items ' ][0 ]['properties ' ]['html-lang ' ]));
77+ } # end method testFragmentHEntryNoLang()
78+
79+ /**
80+ * Test HTML fragment with no lang, loaded with loadXML()
81+ */
82+ public function testFragmentHEntryNoLangXML ()
83+ {
84+ $ input = new \DOMDocument ();
85+ $ input ->loadXML ('<div class="h-entry">This test is in English.</div> ' );
86+ $ parser = new Parser ($ input );
87+ $ result = $ parser ->parse ();
88+
89+ $ this ->assertFalse (isset ($ result ['items ' ][0 ]['properties ' ]['html-lang ' ]));
90+ } # end method testFragmentHEntryNoLangXML()
91+
5592 /**
5693 * Test with different <html lang>, h-entry lang, and h-entry without lang,
5794 * which should inherit from the <html lang>
0 commit comments