diff options
author | Brion Vibber <brion@pobox.com> | 2010-12-14 13:52:44 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-12-14 13:52:44 -0800 |
commit | b7e3b06bb109a54f394311b4ba6bf3ab6a602c1b (patch) | |
tree | 90c4df7cc35dc03f4337e5bfb8933ef3835a2f9a /tests/atompub/atompub_test.php | |
parent | 247a494006dbf276450d74a6a7c38e37ff09f8fe (diff) |
AtomPub tetss: confirming edit URL linked properly in individual entry return
Diffstat (limited to 'tests/atompub/atompub_test.php')
-rw-r--r-- | tests/atompub/atompub_test.php | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/tests/atompub/atompub_test.php b/tests/atompub/atompub_test.php index 36a1ceec2..77934c642 100644 --- a/tests/atompub/atompub_test.php +++ b/tests/atompub/atompub_test.php @@ -188,6 +188,25 @@ class AtomPubClient $activity = new Activity($dom->documentRoot); return true; } + + static function entryEditURL($str) { + $dom = new DOMDocument; + $dom->loadXML($str); + $path = new DOMXPath($dom); + $path->registerNamespace('atom', 'http://www.w3.org/2005/Atom'); + + $links = $path->query('/atom:entry/atom:link[@rel="edit"]', $dom->documentRoot); + if ($links && $links->length) { + if ($links->length > 1) { + throw new Exception('Bad Atom entry; has multiple rel=edit links.'); + } + $link = $links->item(0); + $url = $link->getAttribute('href'); + return $url; + } else { + throw new Exception('Atom entry lists no rel=edit link.'); + } + } } @@ -254,10 +273,12 @@ $body = $notice->get(); AtomPubClient::validateAtomEntry($body); echo "ok\n"; -echo "Confirming new entry looks right... "; -// confirm that it actually is what we expected -// confirm it has an edit URL that matches $target -echo "NYI\n"; +echo "Confirming new entry points to itself right... "; +$editUrl = AtomPubClient::entryEditURL($body); +if ($editUrl != $noticeUrl) { + die("Entry lists edit URL as $editUrl, no match!\n"); +} +echo "OK\n"; echo "Refetching the collection... "; $feed = $collection->get(); |