Add more tests

This commit is contained in:
J. King 2023-06-24 19:36:13 -04:00
parent f7c0574d0d
commit 59d77404e8
4 changed files with 160 additions and 3 deletions

View file

@ -191,7 +191,9 @@ class Parser {
'h:ia' => self::DATE_TYPE_MIN, 'h:ia' => self::DATE_TYPE_MIN,
# HHam HHpm # HHam HHpm
'ha' => self::DATE_TYPE_HOUR, 'ha' => self::DATE_TYPE_HOUR,
// 12-hour clock without hour's leading zero; these are not part of the spec, but definitely occur // time without hour's leading zero; these are not part of the spec, but definitely occur
'G:i:s' => self::DATE_TYPE_SEC,
'G:i' => self::DATE_TYPE_MIN,
'g:i:sa' => self::DATE_TYPE_SEC, 'g:i:sa' => self::DATE_TYPE_SEC,
'g:ia' => self::DATE_TYPE_MIN, 'g:ia' => self::DATE_TYPE_MIN,
'ga' => self::DATE_TYPE_HOUR, 'ga' => self::DATE_TYPE_HOUR,
@ -1006,7 +1008,7 @@ class Parser {
$skipChildren = true; $skipChildren = true;
continue; continue;
} elseif ($node->hasAttribute("title") && in_array("value-title", $classes)) { } elseif ($node->hasAttribute("title") && in_array("value-title", $classes)) {
$candidate = trim($node->getAttribute("title")); $candidate = $node->getAttribute("title");
} elseif (in_array("value", $classes)) { } elseif (in_array("value", $classes)) {
# Where an element with such a microformat property class name # Where an element with such a microformat property class name
# has a descendant with class name value (a "value element") # has a descendant with class name value (a "value element")

View file

@ -125,7 +125,10 @@ class StandardTest extends \PHPUnit\Framework\TestCase {
case "third-party/phpmf2/classic/hentry-tag": case "third-party/phpmf2/classic/hentry-tag":
$this->fixDates($exp['items'][0]['properties']['published']); $this->fixDates($exp['items'][0]['properties']['published']);
break; break;
case "third-party/phpmf2/vcp":
$this->fixDates($exp['items'][5]['properties']['published']);
$exp['items'][7]['properties']['published'][0] = "2013-02-01 06:01";
break;
} }
return $exp; return $exp;
} }

25
tests/cases/third-party/phpmf2/vcp.html vendored Normal file
View file

@ -0,0 +1,25 @@
<div class="h-card"><p class="p-name"><span class="value">Name</span> (this should not be included)</p></div>
<div class="h-card"><p class="p-name"><span class="value">Name</span> (this should not be included) <span class="value">Endname</span></p></div>
<div class="h-card"><p class="p-name"><span class="value-title" title="Real Name">Wrong Name</span> (this should not be included)</p></div>
<div class="h-card"><p class="p-name"><span class="value-title" title="Real ">Wrong Name</span> <span class="value-title" title="Name">(this should not be included)</span></p></div>
<div class="h-entry">
<a href="2013/178/t1/surreal-meeting-dpdpdp-trondisc"
rel="bookmark"
class="dt-published published dt-updated updated u-url u-uid">
<time class="value">10:17</time>
on <time class="value">2013-06-27</time>
</a>
</div>
<div class="h-entry">
<h1 class="p-name">test</h1>
<span class="dt-published"><span class="value-title" title="2012-02-16T16:14:47+00:00"> </span>16.02.2012</span>
</div>
<div class="h-card"><span class="p-tel"><span class="value">1234</span><span class="h-card"><span class="p-tel"><span class="value">5678</span></span></span></span></div>
<div class="h-entry"><span class="dt-published"><time class="value">6:01</time>, <time class="value">2013-02-01</time></span></div>

127
tests/cases/third-party/phpmf2/vcp.json vendored Normal file
View file

@ -0,0 +1,127 @@
{
"items": [
{
"type": [
"h-card"
],
"properties": {
"name": [
"Name"
]
}
},
{
"type": [
"h-card"
],
"properties": {
"name": [
"NameEndname"
]
}
},
{
"type": [
"h-card"
],
"properties": {
"name": [
"Real Name"
]
}
},
{
"type": [
"h-card"
],
"properties": {
"name": [
"Real Name"
]
}
},
{
"type": [
"h-entry"
],
"properties": {
"url": [
"http://example.com/2013/178/t1/surreal-meeting-dpdpdp-trondisc"
],
"uid": [
"http://example.com/2013/178/t1/surreal-meeting-dpdpdp-trondisc"
],
"published": [
"2013-06-27 10:17"
],
"updated": [
"2013-06-27 10:17"
],
"name": [
"10:17 on 2013-06-27"
]
}
},
{
"type": [
"h-entry"
],
"properties": {
"name": [
"test"
],
"published": [
"2012-02-16T16:14:47+00:00"
]
}
},
{
"type": [
"h-card"
],
"properties": {
"tel": [
"1234"
]
},
"children": [
{
"type": [
"h-card"
],
"properties": {
"tel": [
"5678"
]
}
}
]
},
{
"type": [
"h-entry"
],
"properties": {
"published": [
"2013-02-01 6:01"
],
"name": [
"6:01, 2013-02-01"
]
}
}
],
"rels": {
"bookmark": [
"http://example.com/2013/178/t1/surreal-meeting-dpdpdp-trondisc"
]
},
"rel-urls": {
"http://example.com/2013/178/t1/surreal-meeting-dpdpdp-trondisc": {
"text": "10:17 on 2013-06-27",
"rels": [
"bookmark"
]
}
}
}