Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
1 change: 1 addition & 0 deletions Mf2/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}
}
Expand Down
62 changes: 62 additions & 0 deletions tests/Mf2/ClassicMicroformatsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1005,5 +1005,67 @@ 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() {
// 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 = '<div class="vevent">
<a class="summary url" href="https://indieweb.org/2012">
IndieWebCamp 2012
</a>
from <time class="dtstart">2012-06-30</time>
to <time class="dtend">2012-07-01</time> at
<span class="location vcard">
<a class="fn org url" href="https://www.powells.com/">Powell’s</a>,
<span class="adr">
<span class="street-address">1005 W Burnside St.</span>,
<span class="locality">Portland</span>,
<abbr class="region" title="Oregon">OR</abbr>
</span>
</span>
</div>';
$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 = '<div class="vevent">
<span class="summary">CPJ Online Press Freedom Summit</span>
(<time class="dtstart" datetime="2012-10-10">10 Nov 2012</time>) in
<span class="location adr"><span class="street-address">665 3rd St.</span><span class="locality">San Francisco</span>, <span class="region">CA</span> </span>.
</div>';
$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 = '<div class="vevent">
<span class="summary">CPJ Online Press Freedom Summit</span>
(<time class="dtstart" datetime="2012-10-10">10 Nov 2012</time>) in
<span class="location">San Francisco</span>.
</div>';
$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]);
}
}