8000 Fixed language detection to support parsing of HTML fragments by jkphl · Pull Request #121 · microformats/php-mf2 · GitHub
[go: up one dir, main page]

Skip to content

Fixed language detection to support parsing of HTML fragments #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 27, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added XML loading test for HTML fragment language testing (#121)
  • Loading branch information
jkphl committed May 27, 2017
commit f101447a3b04ecd4b012cd7220202a941b0fbd82
25 changes: 25 additions & 0 deletions tests/Mf2/ParseLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,31 @@ public function testFragmentHEntryLangOnly()
$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>
Expand Down
0