forked from ezsystems/ezpublish-spi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EZP-29104: Implemented ImageAsset Field Type (#2403)
* EZP-29104: ImageAsset field type (tests) * EZP-29104: ImageAsset field type (implementation) * EZP-29104: Impl. \eZ\Publish\SPI\FieldType\Indexable for ezimageasset FT
- Loading branch information
Showing
1 changed file
with
112 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?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 eZ\Publish\SPI\Tests\FieldType; | ||
|
||
use eZ\Publish\API\Repository\ContentService; | ||
use eZ\Publish\API\Repository\ContentTypeService; | ||
use eZ\Publish\API\Repository\LocationService; | ||
use eZ\Publish\Core\FieldType; | ||
use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ImageAssetConverter; | ||
use eZ\Publish\SPI\Persistence\Content; | ||
|
||
class ImageAssetIntegrationTest extends BaseIntegrationTest | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getTypeName() | ||
{ | ||
return FieldType\ImageAsset\Type::FIELD_TYPE_IDENTIFIER; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getCustomHandler() | ||
{ | ||
$contentService = $this->createMock(ContentService::class); | ||
$locationService = $this->createMock(LocationService::class); | ||
$contentTypeService = $this->createMock(ContentTypeService::class); | ||
|
||
$config = []; | ||
|
||
$mapper = new FieldType\ImageAsset\AssetMapper( | ||
$contentService, | ||
$locationService, | ||
$contentTypeService, | ||
$config | ||
); | ||
|
||
$fieldType = new FieldType\ImageAsset\Type( | ||
$contentService, | ||
$contentTypeService, | ||
$mapper | ||
); | ||
|
||
$fieldType->setTransformationProcessor($this->getTransformationProcessor()); | ||
|
||
return $this->getHandler( | ||
'ezimageasset', | ||
$fieldType, | ||
new ImageAssetConverter(), | ||
new FieldType\NullStorage() | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getTypeConstraints() | ||
{ | ||
return new Content\FieldTypeConstraints(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFieldDefinitionData() | ||
{ | ||
return [ | ||
['fieldType', 'ezimageasset'], | ||
['fieldTypeConstraints', new Content\FieldTypeConstraints(['fieldSettings' => null])], | ||
]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getInitialValue() | ||
{ | ||
return new Content\FieldValue( | ||
[ | ||
'data' => [ | ||
'destinationContentId' => 1, | ||
], | ||
'externalData' => null, | ||
'sortKey' => null, | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getUpdatedValue() | ||
{ | ||
return new Content\FieldValue( | ||
[ | ||
'data' => [ | ||
'destinationContentId' => 2, | ||
], | ||
'externalData' => null, | ||
'sortKey' => null, | ||
] | ||
); | ||
} | ||
} |