Skip to content

Commit b0373f5

Browse files
committed
Switch to array_key_exists to check presence. Update tests to not require 'eels' key, just check the array.
1 parent a4db616 commit b0373f5

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

src/IndieWeb/link_rel_parser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function http_rels($h) {
3333
foreach ($relarray as $rel) {
3434
$rel = strtolower(trim($rel));
3535
if ($rel != '') {
36-
if (!$rels[$rel]) {
36+
if (!array_key_exists($rel, $rels)) {
3737
$rels[$rel] = array();
3838
}
3939
if (!in_array($href, $rels[$rel])) {

tests/BasicTest.php

+8-17
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,28 @@ private function _testEquals($expected, $headers) {
1111

1212
public function testExample() {
1313
$this->_testEquals(array(
14-
'rels' => array(
15-
'd' => array('http://example.org/query?a=b,c'),
16-
'e' => array('http://example.org/query?a=b,c'),
17-
'f' => array('http://example.org/'),
18-
)
14+
'd' => array('http://example.org/query?a=b,c'),
15+
'e' => array('http://example.org/query?a=b,c'),
16+
'f' => array('http://example.org/'),
1917
), "Link: <http://example.org/query?a=b,c>; rel=\"d e\", <http://example.org/>; rel=f");
2018
}
2119

2220
public function testMultipleAttributes() {
2321
$this->_testEquals(array(
24-
'rels' => array(
25-
'foo' => array('http://example.org/'),
26-
)
22+
'foo' => array('http://example.org/'),
2723
), "Link: <http://example.org/>; rel=\"foo\"; title=\"Example\"");
2824
}
2925

3026
public function testLinkNoRelValue() {
3127
$this->_testEquals(array(
32-
'rels' => array(
33-
)
3428
), "Link: <http://example.org/>; title=\"Example\"");
3529
}
3630

3731
public function testAaronParecki() {
3832
$this->_testEquals(array(
39-
'rels' => array(
40-
'http://webmention.org/' => array('http://aaronparecki.com/webmention.php'),
41-
'indieauth' => array('https://indieauth.com'),
42-
)
33+
'http://webmention.org/' => array('http://aaronparecki.com/webmention.php'),
34+
'indieauth' => array('https://indieauth.com'),
35+
'pingback' => array('http://pingback.me/webmention?forward=http%3A%2F%2Faaronparecki.com%2Fwebmention.php')
4336
), "HTTP/1.1 200 OK
4437
Server: nginx/1.0.14
4538
Date: Sat, 26 Oct 2013 01:40:11 GMT
@@ -52,9 +45,7 @@ public function testAaronParecki() {
5245

5346
public function testBarryFrost() {
5447
$this->_testEquals(array(
55-
'rels' => array(
56-
'webmention' => array('http://barryfrost.com/webmention'),
57-
)
48+
'webmention' => array('http://barryfrost.com/webmention'),
5849
), "HTTP/1.1 200 OK
5950
Cache-Control: max-age=0, private, must-revalidate
6051
Content-length: 19600

0 commit comments

Comments
 (0)