From da8b5ec22c98b0f015b59d23a0ffef47c34744a5 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Fri, 25 Oct 2013 18:57:06 -0700 Subject: [PATCH] Add test suite around parsing function --- composer.json | 21 ++++++++++++++++ phpunit.xml | 8 +++++++ src/IndieWeb/link_rel_parser.php | 11 +++++++++ tests/BasicTest.php | 52 ++++++++++++++++++++++++++++++++++++++++ tests/bootstrap.php | 4 ++++ 5 files changed, 96 insertions(+) create mode 100644 composer.json create mode 100644 phpunit.xml create mode 100644 src/IndieWeb/link_rel_parser.php create mode 100644 tests/BasicTest.php create mode 100644 tests/bootstrap.php diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..83ab434 --- /dev/null +++ b/composer.json @@ -0,0 +1,21 @@ +{ + "name": "indieweb/link-rel-parser", + "type": "library", + "description": "Parse rel values from HTTP headers", + "keywords": ["indieweb", "http", "microformats2"], + "license": "Apache-2.0", + "homepage": "https://github.com/indieweb/link-rel-parser-php", + "authors" : [ + { + "name": "Tantek Çelik", + "homepage": "http://tantek.com" + }, + { + "name": "Aaron Parecki", + "homepage": "http://aaronparecki.com" + } + ], + "require": { + "php": ">=5.3.0" + } +} \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..9e95f03 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,8 @@ + + + + + tests + + + \ No newline at end of file diff --git a/src/IndieWeb/link_rel_parser.php b/src/IndieWeb/link_rel_parser.php new file mode 100644 index 0000000..425c5e6 --- /dev/null +++ b/src/IndieWeb/link_rel_parser.php @@ -0,0 +1,11 @@ + array() + ); +} diff --git a/tests/BasicTest.php b/tests/BasicTest.php new file mode 100644 index 0000000..60589e6 --- /dev/null +++ b/tests/BasicTest.php @@ -0,0 +1,52 @@ +assertEquals($expected, $result); + } + + public function testInvalidStartDate() { + $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/'), + ) + ), "Link: ; rel=\"d e\", ; rel=f"); + } + + public function testAaronParecki() { + $this->_testEquals(array( + 'rels' => array( + 'http://webmention.org/' => array('http://aaronparecki.com/webmention.php'), + 'indieauth' => array('https://indieauth.com'), + ) + ), "HTTP/1.1 200 OK +Server: nginx/1.0.14 +Date: Sat, 26 Oct 2013 01:40:11 GMT +Content-Type: text/html; charset=UTF-8 +Connection: keep-alive +Link: ; rel=\"indieauth\" +X-Pingback: http://pingback.me/webmention?forward=http%3A%2F%2Faaronparecki.com%2Fwebmention.php +Link: ; rel=\"http://webmention.org/\""); + } + + public function testBarryFrost() { + $this->_testEquals(array( + 'rels' => array( + 'webmention' => array('http://aaronparecki.com/webmention.php'), + ) + ), "HTTP/1.1 200 OK +Cache-Control: max-age=0, private, must-revalidate +Content-length: 19600 +Content-Type: text/html; charset=utf-8 +Date: Sat, 26 Oct 2013 01:49:21 GMT +Link: ; rel=\"webmention\""); + } + + +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..69cbd1b --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,4 @@ +