From 0f26d6eb70dc410bac6ec66161bf11b2f6a80fc0 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 14 Dec 2010 13:11:34 -0800 Subject: [PATCH] more fixins on AtomPub tests --- tests/atompub/atompub_test.php | 36 +++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/tests/atompub/atompub_test.php b/tests/atompub/atompub_test.php index 99a0981e5f..cc1f93b44c 100644 --- a/tests/atompub/atompub_test.php +++ b/tests/atompub/atompub_test.php @@ -65,8 +65,8 @@ class AtomPubClient */ private function httpClient($method='GET') { - $client = new HTTPClient($this->url, 'GET'); - // basic auth, whee + $client = new HTTPClient($this->url); + $client->setMethod($method); $client->setAuth($this->user, $this->pass); return $client; } @@ -211,9 +211,39 @@ $collection = new AtomPubClient($url, $user, $pass); // confirm the feed has edit links ..... ? -// $atom = ''; +echo "Posting an empty message (should fail)... "; +try { + $noticeUrl = $collection->post(''); + die("FAILED, succeeded!\n"); +} catch (Exception $e) { + echo "ok\n"; +} + +echo "Posting an invalid XML message (should fail)... "; +try { + $noticeUrl = $collection->post('barf'); + die("FAILED, succeeded!\n"); +} catch (Exception $e) { + echo "ok\n"; +} + +echo "Posting a valid XML but non-Atom message (should fail)... "; +try { + $noticeUrl = $collection->post('arfbarf'); + die("FAILED, succeeded!\n"); +} catch (Exception $e) { + echo "ok\n"; +} // post! +$rand = mt_rand(0, 99999); +$atom = << + This is an AtomPub test post title ($rand) + This is an AtomPub test post content ($rand) + +END_ATOM; + echo "Posting a new message... "; $noticeUrl = $collection->post($atom); echo "ok, got $noticeUrl\n"; -- 2.39.5