BUGFIX Unit tests for RestfulServer (see r64439)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@64440 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-10-16 17:35:59 +00:00
parent 118efae75d
commit c0a94a7c82
1 changed files with 14 additions and 2 deletions

View File

@ -156,7 +156,7 @@ class RestfulServerTest extends SapphireTest {
unset($_SERVER['PHP_AUTH_USER']);
unset($_SERVER['PHP_AUTH_PW']);
}
public function testHTTPAcceptAndContentType() {
$url = "/api/v1/RestfulServerTest_Comment/1";
@ -186,11 +186,19 @@ class RestfulServerTest extends SapphireTest {
$this->assertEquals($response->getStatusCode(), 405);
}
public function testConflictOnExistingResourceWhenUsingPost() {
$rating1 = $this->objFromFixture('RestfulServerTest_AuthorRating', 'rating1');
$url = "/api/v1/RestfulServerTest_AuthorRating/" . $rating1->ID;
$response = Director::test($url, null, null, 'POST');
$this->assertEquals($response->getStatusCode(), 409);
}
public function testUnsupportedMediaType() {
$_SERVER['PHP_AUTH_USER'] = 'user@test.com';
$_SERVER['PHP_AUTH_PW'] = 'user';
$url = "/api/v1/RestfulServerTest_Comment/1";
$url = "/api/v1/RestfulServerTest_Comment";
$data = "Comment||\/||updated"; // weird format
$headers = array('Content-Type' => 'text/weirdformat');
$response = Director::test($url, null, null, 'POST', $data, $headers);
@ -340,6 +348,10 @@ class RestfulServerTest_Page extends DataObject implements TestOnly {
'Title' => 'Text',
'Content' => 'HTMLText',
);
static $has_many = array(
'TestComments' => 'RestfulServerTest_Comment'
);
}