more fixins on AtomPub tests

This commit is contained in:
Brion Vibber 2010-12-14 13:11:34 -08:00
parent 56e72ec7a1
commit 0f26d6eb70

View File

@ -65,8 +65,8 @@ class AtomPubClient
*/ */
private function httpClient($method='GET') private function httpClient($method='GET')
{ {
$client = new HTTPClient($this->url, 'GET'); $client = new HTTPClient($this->url);
// basic auth, whee $client->setMethod($method);
$client->setAuth($this->user, $this->pass); $client->setAuth($this->user, $this->pass);
return $client; return $client;
} }
@ -211,9 +211,39 @@ $collection = new AtomPubClient($url, $user, $pass);
// confirm the feed has edit links ..... ? // 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('<feed<entry>barf</yomomma>');
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('<feed xmlns="http://notatom.com"><id>arf</id><entry><id>barf</id></entry></feed>');
die("FAILED, succeeded!\n");
} catch (Exception $e) {
echo "ok\n";
}
// post! // post!
$rand = mt_rand(0, 99999);
$atom = <<<END_ATOM
<entry xmlns="http://www.w3.org/2005/Atom">
<title>This is an AtomPub test post title ($rand)</title>
<content>This is an AtomPub test post content ($rand)</content>
</entry>
END_ATOM;
echo "Posting a new message... "; echo "Posting a new message... ";
$noticeUrl = $collection->post($atom); $noticeUrl = $collection->post($atom);
echo "ok, got $noticeUrl\n"; echo "ok, got $noticeUrl\n";