public testCreateContent ( ) : string | ||
return | string | REST content ID |
public function testCreateContent()
{
$request = $this->createHttpRequest('POST', '/api/ezp/v2/content/objects', 'ContentCreate+xml', 'ContentInfo+json');
$string = $this->addTestSuffix(__FUNCTION__);
$body = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<ContentCreate>
<ContentType href="/api/ezp/v2/content/types/1" />
<mainLanguageCode>eng-GB</mainLanguageCode>
<LocationCreate>
<ParentLocation href="/api/ezp/v2/content/locations/1/2" />
<priority>0</priority>
<hidden>false</hidden>
<sortField>PATH</sortField>
<sortOrder>ASC</sortOrder>
</LocationCreate>
<Section href="/api/ezp/v2/content/sections/1" />
<alwaysAvailable>true</alwaysAvailable>
<remoteId>{$string}</remoteId>
<User href="/api/ezp/v2/user/users/14" />
<modificationDate>2012-09-30T12:30:00</modificationDate>
<fields>
<field>
<fieldDefinitionIdentifier>name</fieldDefinitionIdentifier>
<languageCode>eng-GB</languageCode>
<fieldValue>{$string}</fieldValue>
</field>
</fields>
</ContentCreate>
XML;
$request->setContent($body);
$response = $this->sendHttpRequest($request);
self::assertHttpResponseCodeEquals($response, 201);
self::assertHttpResponseHasHeader($response, 'Location');
$href = $response->getHeader('Location');
$this->addCreatedElement($href);
return $href;
}