Skip to content

Run mf2/tests test suite with PHPUnit during default testing #163

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 17 commits into from
Jun 13, 2020
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
Next Next commit
Remove consecutive whitespace when comparing tests
As discussed previously php-mf2 has custom handling of textContent to
match with what consumers were expecting to get back. This means all
tests around plain text output have a high tendency to fail.

This change addresses that a little by ignoring whitespace differences
within e-* properties.
  • Loading branch information
Zegnat committed May 27, 2020
commit 18bb4cf16a1dab6d75b9280aac7938b0a8ddae80
6 changes: 6 additions & 0 deletions tests/Mf2/MicroformatsTestSuiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function testMixedFromTestSuite($input, $expectedOutput)
* * We sort arrays by key, normalising them, because JSON objects are unordered.
* * We json_encode strings, and cut the starting and ending ", so PHPUnit better
* shows whitespace characters like tabs and newlines.
* * We replace all consecutive whitespace with single space characters in e-* value
* properties, to avoid failing tests only because difference in the handing of
* extracting textContent.
**/
public function makeComparible($array)
{
Expand All @@ -56,6 +59,9 @@ public function makeComparible($array)
if (gettype($value) === 'array') {
$array[$key] = $this->makeComparible($value);
} else if (gettype($value) === 'string') {
if ($key === 'value' && array_key_exists('html', $array)) {
$value = preg_replace('/\s+/', ' ', $value);
}
$array[$key] = substr(json_encode($value), 1, -1);
}
}
Expand Down