Skip to content
Browse files

Add test suite around parsing function

  • Loading branch information...
1 parent 2f36044 commit da8b5ec22c98b0f015b59d23a0ffef47c34744a5 @aaronpk aaronpk committed Oct 25, 2013
Showing with 96 additions and 0 deletions.
  1. +21 −0 composer.json
  2. +8 −0 phpunit.xml
  3. +11 −0 src/IndieWeb/link_rel_parser.php
  4. +52 −0 tests/BasicTest.php
  5. +4 −0 tests/bootstrap.php
View
21 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"
+ }
+}
View
8 phpunit.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<phpunit bootstrap="tests/bootstrap.php">
+ <testsuites>
+ <testsuite name="date-formatter">
+ <directory suffix="Test.php">tests</directory>
+ </testsuite>
+ </testsuites>
+</phpunit>
View
11 src/IndieWeb/link_rel_parser.php
@@ -0,0 +1,11 @@
+<?php
+namespace IndieWeb;
+
+function http_rels($headerString) {
+
+ // TODO: Implement this
+
+ return array(
+ 'rels' => array()
+ );
+}
View
52 tests/BasicTest.php
@@ -0,0 +1,52 @@
+<?php
+class BasicTest extends PHPUnit_Framework_TestCase {
+
+ public function setUp() {
+ }
+
+ private function _testEquals($expected, $headers) {
+ $result = IndieWeb\http_rels($headers);
+ $this->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: <http://example.org/query?a=b,c>; rel=\"d e\", <http://example.org/>; 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: <https://indieauth.com>; rel=\"indieauth\"
+X-Pingback: http://pingback.me/webmention?forward=http%3A%2F%2Faaronparecki.com%2Fwebmention.php
+Link: <http://aaronparecki.com/webmention.php>; 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: <http://barryfrost.com/webmention>; rel=\"webmention\"");
+ }
+
+
+}
View
4 tests/bootstrap.php
@@ -0,0 +1,4 @@
+<?php
+
+require dirname(__DIR__) . '/src/IndieWeb/link_rel_parser.php';
+

0 comments on commit da8b5ec

Please sign in to comment.
Something went wrong with that request. Please try again.