Skip to content

Commit

Permalink
Add failing test and fix for microformats#198
Browse files Browse the repository at this point in the history
  • Loading branch information
gRegorLove committed Nov 21, 2018
1 parent 00b70ee commit fde7985
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Mf2/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ public function parseH(\DOMElement $e, $is_backcompat = false, $has_nested_mf =
}

// Check for u-photo
if (!array_key_exists('photo', $return) && !$is_backcompat) {
if (!array_key_exists('photo', $return) && !in_array('u-', $prefixes) && !$is_backcompat) {

$photo = $this->parseImpliedPhoto($e);

Expand Down
11 changes: 11 additions & 0 deletions tests/Mf2/ParseImpliedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,5 +375,16 @@ public function testNoImgSrcImpliedName() {
$this->assertArrayHasKey('name', $result['items'][0]['properties']);
$this->assertEquals('My Name', $result['items'][0]['properties']['name'][0]);
}

/**
* @see https://github.com/microformats/php-mf2/issues/198
*/
public function testNoImipliedPhoto() {
$input = '<div class="h-card"> <span class="p-org">Organization Name</span> <img src="/logo.png" class="u-logo" alt=""> </div>';
$result = Mf2\parse($input);

$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
}

}

0 comments on commit fde7985

Please sign in to comment.