From 113b0a4cc720a537c4f004f26e7a237d9bc34f03 Mon Sep 17 00:00:00 2001 From: Gregor Morrill Date: Thu, 7 Jul 2022 20:55:22 -0700 Subject: [PATCH 1/3] Update tests demonstrating #184 already fixed --- Mf2/Parser.php | 1 + tests/Mf2/ClassicMicroformatsTest.php | 60 +++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/Mf2/Parser.php b/Mf2/Parser.php index 7ac471e..c80509e 100644 --- a/Mf2/Parser.php +++ b/Mf2/Parser.php @@ -1658,6 +1658,7 @@ public function backcompat(DOMElement $el, $context = '', $isParentMf2 = false) if ( !$this->hasRootMf2($tempEl) ) { $this->addMfClasses($tempEl, 'p-location h-card'); $this->backcompat($tempEl, 'vcard'); + $this->addUpgraded($tempEl, array('location', 'vcard')); } } } diff --git a/tests/Mf2/ClassicMicroformatsTest.php b/tests/Mf2/ClassicMicroformatsTest.php index 5b192c3..6531783 100644 --- a/tests/Mf2/ClassicMicroformatsTest.php +++ b/tests/Mf2/ClassicMicroformatsTest.php @@ -1005,5 +1005,65 @@ public function testVcardGeoNoImpliedName() { $this->assertArrayNotHasKey('name', $output['items'][0]['properties']['geo'][0]['properties']); } + + /** + * @see https://github.com/microformats/php-mf2/issues/184 + */ + public function testVeventLocationVcardProperty() { + $input = '
+ + IndieWebCamp 2012 + + from + to at + + Geoloqi, + + 920 SW 3rd Ave. Suite 400, + Portland, + OR + + +
'; + $parser = new Parser($input, 'https://example.com'); + $output = $parser->parse(); + + $this->assertArrayHasKey('location', $output['items'][0]['properties']); + $this->assertCount(1, $output['items'][0]['properties']['location'][0]['type']); + $this->assertEquals('h-card', $output['items'][0]['properties']['location'][0]['type'][0]); + } + + /** + * @see https://github.com/microformats/php-mf2/issues/184 + */ + public function testVeventLocationAdrProperty() { + $input = '
+ CPJ Online Press Freedom Summit + () in + 665 3rd St.San Francisco, CA . +
'; + $parser = new Parser($input, 'https://example.com'); + $output = $parser->parse(); + + $this->assertArrayHasKey('location', $output['items'][0]['properties']); + $this->assertCount(1, $output['items'][0]['properties']['location'][0]['type']); + $this->assertEquals('h-adr', $output['items'][0]['properties']['location'][0]['type'][0]); + } + + /** + * @see https://github.com/microformats/php-mf2/issues/184 + */ + public function testVeventLocationProperty() { + $input = '
+ CPJ Online Press Freedom Summit + () in + San Francisco. +
'; + $parser = new Parser($input, 'https://example.com'); + $output = $parser->parse(); + + $this->assertArrayHasKey('location', $output['items'][0]['properties']); + $this->assertEquals('San Francisco', $output['items'][0]['properties']['location'][0]); + } } From fa5f86bece67178ee038ce98bb9fe49a4d94d59f Mon Sep 17 00:00:00 2001 From: Gregor Morrill Date: Fri, 8 Mar 2024 11:26:34 -0800 Subject: [PATCH 2/3] Update hreview backcompat test Use Powell's for vcard --- tests/Mf2/ClassicMicroformatsTest.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/Mf2/ClassicMicroformatsTest.php b/tests/Mf2/ClassicMicroformatsTest.php index 6531783..b7a4535 100644 --- a/tests/Mf2/ClassicMicroformatsTest.php +++ b/tests/Mf2/ClassicMicroformatsTest.php @@ -1010,16 +1010,18 @@ public function testVcardGeoNoImpliedName() { * @see https://github.com/microformats/php-mf2/issues/184 */ public function testVeventLocationVcardProperty() { + // Note: The venue for IWC 2012 no longer exists so we switched + // this to Powell's since it's a long-term Portland institution $input = '
- + IndieWebCamp 2012 from to at - Geoloqi, + Powell’s, - 920 SW 3rd Ave. Suite 400, + 1005 W Burnside St., Portland, OR From 8f07793edbe281e76b91e2a9274f03f04a4d7f0e Mon Sep 17 00:00:00 2001 From: Gregor Morrill Date: Fri, 8 Mar 2024 12:54:18 -0800 Subject: [PATCH 3/3] Fix date in tests --- tests/Mf2/ClassicMicroformatsTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/Mf2/ClassicMicroformatsTest.php b/tests/Mf2/ClassicMicroformatsTest.php index b7a4535..1aa2a80 100644 --- a/tests/Mf2/ClassicMicroformatsTest.php +++ b/tests/Mf2/ClassicMicroformatsTest.php @@ -1039,9 +1039,11 @@ public function testVeventLocationVcardProperty() { * @see https://github.com/microformats/php-mf2/issues/184 */ public function testVeventLocationAdrProperty() { + // date fix, see: https://cpj.org/2012/10/cpj-impact-43/ + // "second annual Online Press Freedom Summit in San Francisco on October 10" $input = '
CPJ Online Press Freedom Summit - () in + () in 665 3rd St.San Francisco, CA .
'; $parser = new Parser($input, 'https://example.com'); @@ -1056,9 +1058,11 @@ public function testVeventLocationAdrProperty() { * @see https://github.com/microformats/php-mf2/issues/184 */ public function testVeventLocationProperty() { + // date fix, see: https://cpj.org/2012/10/cpj-impact-43/ + // "second annual Online Press Freedom Summit in San Francisco on October 10" $input = '
CPJ Online Press Freedom Summit - () in + () in San Francisco.
'; $parser = new Parser($input, 'https://example.com');