-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Content Type for Image Variation
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace EzSystems\EzPlatformRestBundle\Tests\Functional; | ||
|
||
use EzSystems\EzPlatformRestBundle\Tests\Functional\TestCase as RESTFunctionalTestCase; | ||
|
||
final class ImageVariationTest extends RESTFunctionalTestCase | ||
{ | ||
public function testCreateContent(): void | ||
{ | ||
// Targets | ||
$contentTypeId = 5; // "Image" | ||
$parentLocationPath = '1/43/51'; // "Media > Images" | ||
$sectionId = 3; // "Media" | ||
|
||
$fileName = basename('1px image.png'); | ||
$fileContent = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wAAAZABAcM/pFYAAAAASUVORK5CYII='; | ||
$fileSize = 1; | ||
$name = $fileName; | ||
|
||
$api = '/api/ezp/v2'; | ||
$body = <<<XML | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ContentCreate> | ||
<ContentType href="{$api}/content/types/{$contentTypeId}" /> | ||
<mainLanguageCode>eng-GB</mainLanguageCode> | ||
<LocationCreate> | ||
<ParentLocation href="{$api}/content/locations/{$parentLocationPath}" /> | ||
<sortField>PATH</sortField> | ||
<sortOrder>ASC</sortOrder> | ||
</LocationCreate> | ||
<Section href="{$api}/content/sections/{$sectionId}" /> | ||
<fields> | ||
<field> | ||
<fieldDefinitionIdentifier>name</fieldDefinitionIdentifier> | ||
<fieldValue>{$name}</fieldValue> | ||
</field> | ||
<field> | ||
<fieldDefinitionIdentifier>caption</fieldDefinitionIdentifier> | ||
<fieldValue> | ||
<value key="xml"><![CDATA[<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5/edit"><h1>{$name}</h1></section>]]></value> | ||
</fieldValue> | ||
</field> | ||
<field> | ||
<fieldDefinitionIdentifier>image</fieldDefinitionIdentifier> | ||
<fieldValue> | ||
<value key="fileName">{$fileName}</value> | ||
<value key="fileSize">{$fileSize}</value> | ||
<value key="data"><![CDATA[{$fileContent}]]></value> | ||
</fieldValue> | ||
</field> | ||
</fields> | ||
</ContentCreate> | ||
XML; | ||
|
||
$request = $this->createHttpRequest( | ||
'POST', | ||
'/api/ezp/v2/content/objects', | ||
'ContentCreate+xml', | ||
'ContentInfo+xml', | ||
$body | ||
); | ||
|
||
$response = $this->sendHttpRequest($request); | ||
|
||
self::assertEquals('201', $response->getStatusCode()); | ||
|
||
$href = $response->getHeader('Location')[0]; | ||
var_dump($href, (string)$response->getBody());d | ||
} | ||
Check failure on line 76 in tests/bundle/Functional/ImageVariationTest.php GitHub Actions / Unit tests (7.3)
Check failure on line 76 in tests/bundle/Functional/ImageVariationTest.php GitHub Actions / Unit tests (7.4)
Check failure on line 76 in tests/bundle/Functional/ImageVariationTest.php GitHub Actions / Unit tests (8.0)
|
||
} |