Unverified Commit d17880c8 authored by Aaron Parecki's avatar Aaron Parecki

Merge branch 'master' of github.com:indieweb/php-mf2

parents b334c707 84bd6efa
......@@ -508,7 +508,7 @@ class Parser {
return unicodeTrim($node->getAttribute('content'));
}
}
} else {
} elseif ($el->parentNode instanceof DOMElement) {
// check the parent node
return $this->language($el->parentNode);
}
......
......@@ -52,6 +52,43 @@ class ParseLanguageTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('es', $result['items'][0]['properties']['html-lang']);
} # end method testHtmlAndHEntryLang()
/**
* Test HTML fragment with only h-entry lang
*/
public function testFragmentHEntryLangOnly()
{
$input = '<div class="h-entry" lang="en">This test is in English.</div>';
$parser = new Parser($input);
$result = $parser->parse();
$this->assertEquals('en', $result['items'][0]['properties']['html-lang']);
} # end method testFragmentHEntryLangOnly()
/**
* Test HTML fragment with no lang
*/
public function testFragmentHEntryNoLang()
{
$input = '<div class="h-entry">This test is in English.</div>';
$parser = new Parser($input);
$result = $parser->parse();
$this->assertFalse(isset($result['items'][0]['properties']['html-lang']));
} # end method testFragmentHEntryNoLang()
/**
* Test HTML fragment with no lang, loaded with loadXML()
*/
public function testFragmentHEntryNoLangXML()
{
$input = new \DOMDocument();
$input->loadXML('<div class="h-entry">This test is in English.</div>');
$parser = new Parser($input);
$result = $parser->parse();
$this->assertFalse(isset($result['items'][0]['properties']['html-lang']));
} # end method testFragmentHEntryNoLangXML()
/**
* Test with different <html lang>, h-entry lang, and h-entry without lang,
* which should inherit from the <html lang>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment