From fde7985276620a10599257a64665e09f6385a930 Mon Sep 17 00:00:00 2001 From: Gregor Morrill Date: Tue, 20 Nov 2018 18:23:39 -0800 Subject: [PATCH 1/3] Add failing test and fix for #198 --- Mf2/Parser.php | 2 +- tests/Mf2/ParseImpliedTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Mf2/Parser.php b/Mf2/Parser.php index fe5590b..07de4c3 100644 --- a/Mf2/Parser.php +++ b/Mf2/Parser.php @@ -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); diff --git a/tests/Mf2/ParseImpliedTest.php b/tests/Mf2/ParseImpliedTest.php index e12ed00..bb110a9 100644 --- a/tests/Mf2/ParseImpliedTest.php +++ b/tests/Mf2/ParseImpliedTest.php @@ -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 = '
Organization Name
'; + $result = Mf2\parse($input); + + $this->assertArrayNotHasKey('photo', $result['items'][0]['properties']); + } + } From 79aa127b2d8ecfa33f019ae392f942bb611087fc Mon Sep 17 00:00:00 2001 From: Gregor Morrill Date: Wed, 15 May 2019 00:49:40 -0700 Subject: [PATCH 2/3] Add another failing test and fix Test for no implied photo when there is a nested microformat. --- Mf2/Parser.php | 5 +---- tests/Mf2/ParseImpliedTest.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Mf2/Parser.php b/Mf2/Parser.php index 07de4c3..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) && !in_array('u-', $prefixes) && !$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 bb110a9..b70fb75 100644 --- a/tests/Mf2/ParseImpliedTest.php +++ b/tests/Mf2/ParseImpliedTest.php @@ -379,12 +379,23 @@ public function testNoImgSrcImpliedName() { /** * @see https://github.com/microformats/php-mf2/issues/198 */ - public function testNoImipliedPhoto() { + 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']); + } } From f0c9a9128ff0bd4ce3f096a038bb08fdb4c38eef Mon Sep 17 00:00:00 2001 From: Gregor Morrill Date: Tue, 21 May 2019 23:41:47 -0700 Subject: [PATCH 3/3] Update .travis.yml Add PHP 7.3. Allow PHP nightly to fail. Allow fast finish for builds allowed to fail. --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) 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