Skip to content

Commit

Permalink
Switch to array_key_exists to check presence. Update tests to not req…
Browse files Browse the repository at this point in the history
…uire 'eels' key, just check the array.
  • Loading branch information
aaronpk committed Oct 26, 2013
1 parent a4db616 commit b0373f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/IndieWeb/link_rel_parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function http_rels($h) {
foreach ($relarray as $rel) {
$rel = strtolower(trim($rel));
if ($rel != '') {
if (!$rels[$rel]) {
if (!array_key_exists($rel, $rels)) {
$rels[$rel] = array();
}
if (!in_array($href, $rels[$rel])) {
Expand Down
25 changes: 8 additions & 17 deletions tests/BasicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,28 @@ private function _testEquals($expected, $headers) {

public function testExample() {
$this->_testEquals(array(
'rels' => array(
'd' => array('http://example.org/query?a=b,c'),
'e' => array('http://example.org/query?a=b,c'),
'f' => array('http://example.org/'),
)
'd' => array('http://example.org/query?a=b,c'),
'e' => array('http://example.org/query?a=b,c'),
'f' => array('http://example.org/'),
), "Link: <http://example.org/query?a=b,c>; rel=\"d e\", <http://example.org/>; rel=f");
}

public function testMultipleAttributes() {
$this->_testEquals(array(
'rels' => array(
'foo' => array('http://example.org/'),
)
'foo' => array('http://example.org/'),
), "Link: <http://example.org/>; rel=\"foo\"; title=\"Example\"");
}

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

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

public function testBarryFrost() {
$this->_testEquals(array(
'rels' => array(
'webmention' => array('http://barryfrost.com/webmention'),
)
'webmention' => array('http://barryfrost.com/webmention'),
), "HTTP/1.1 200 OK
Cache-Control: max-age=0, private, must-revalidate
Content-length: 19600
Expand Down

0 comments on commit b0373f5

Please sign in to comment.