function RestWSTestCase::testXmlFormatter in RESTful Web Services 7
Same name and namespace in other branches
- 7.2 restws.test \RestWSTestCase::testXmlFormatter()
Tests using the xml formatter.
File
- ./
restws.test, line 227 - RESTful web services tests.
Class
- RestWSTestCase
- @file RESTful web services tests.
Code
function testXmlFormatter() {
// Test Read.
$account = $this
->drupalCreateUser(array(
'access content',
'bypass node access',
'access resource node',
));
$this
->drupalLogin($account);
$title = $this
->randomName(8);
$node = $this
->drupalCreateNode(array(
'title' => $title,
));
$result = $this
->drupalGet("node/{$node->nid}", array(), array(
'Accept: application/xml',
));
$this
->assertRaw("<title>{$title}</title>", 'XML has been generated.');
// Test update.
$new_title = 'foo';
$result = $this
->httpRequest('node/' . $node->nid, 'POST', $account, "<node><title>{$new_title}</title></node>", 'xml');
// Clear the static cache, otherwise we won't see the update.
$node = node_load($node->nid, NULL, TRUE);
$this
->assertEqual($new_title, $node->title, 'Node title in DB is equal to the updated title.');
$this
->assertResponse('200', 'HTTP response code is correct.');
$this
->assertEqual(curl_getinfo($this->curlHandle, CURLINFO_CONTENT_TYPE), 'application/xml', 'HTTP content type is correct.');
}