diff --git a/.travis.yml b/.travis.yml index 799c58e..4ee293a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,15 @@ php: - 7.0 - 7.1 - 7.2 + - 7.3 - nightly env: - COMPOSER_REQUIRE="" - COMPOSER_REQUIRE="composer require masterminds/html5" +matrix: + fast_finish: true + allow_failures: + - php: nightly install: - $COMPOSER_REQUIRE before_script: composer install diff --git a/Mf2/Parser.php b/Mf2/Parser.php index fe5590b..f2c91b7 100644 --- a/Mf2/Parser.php +++ b/Mf2/Parser.php @@ -1090,14 +1090,11 @@ 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) && !$has_nested_mf && !$is_backcompat) { $photo = $this->parseImpliedPhoto($e); - if ($photo !== false) { $return['photo'][] = $photo; } - } // Do we need to imply a url property? diff --git a/tests/Mf2/ParseImpliedTest.php b/tests/Mf2/ParseImpliedTest.php index e12ed00..b70fb75 100644 --- a/tests/Mf2/ParseImpliedTest.php +++ b/tests/Mf2/ParseImpliedTest.php @@ -375,5 +375,27 @@ 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 testNoImpliedPhotoWhenExplicitUProperty() { + $input = '
Organization Name
'; + $result = Mf2\parse($input); + + $this->assertArrayNotHasKey('photo', $result['items'][0]['properties']); + } + + /** + * @see https://github.com/microformats/php-mf2/issues/198 + */ + public function testNoImpliedPhotoWhenNestedMicroformat() { + $input = '
Alice Organization Name
'; + $result = Mf2\parse($input); + + $this->assertArrayNotHasKey('photo', $result['items'][0]['properties']); + $this->assertArrayHasKey('author', $result['items'][0]['properties']); + $this->assertArrayNotHasKey('photo', $result['items'][0]['properties']['author'][0]['properties']); + } }