public testLoadContentTypes ( ) : array | ||
return | array |
public function testLoadContentTypes()
{
$contentTypeService = $this->repository->getContentTypeService();
$groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('test-group-1');
$groupCreate->creatorId = $this->repository->getCurrentUserReference()->getUserId();
$groupCreate->creationDate = new \DateTime();
// @todo uncomment when support for multilingual names and descriptions is added EZP-24776
//$groupCreate->mainLanguageCode = 'ger-DE';
//$groupCreate->names = array( 'eng-US' => 'A name.' );
//$groupCreate->descriptions = array( 'eng-US' => 'A description.' );
$group = $contentTypeService->createContentTypeGroup($groupCreate);
$typeCreateStruct = $contentTypeService->newContentTypeCreateStruct('test-type-1');
$typeCreateStruct->names = array('eng-US' => 'American type title', 'eng-GB' => 'British type title');
$typeCreateStruct->descriptions = array('eng-US' => 'American type description', 'eng-GB' => 'British type description');
$typeCreateStruct->remoteId = 'test-remoteid-1';
$typeCreateStruct->creatorId = $this->repository->getCurrentUserReference()->getUserId();
$typeCreateStruct->creationDate = new \DateTime();
$typeCreateStruct->mainLanguageCode = 'eng-GB';
$typeCreateStruct->nameSchema = '<name>';
$typeCreateStruct->urlAliasSchema = '<name>';
$titleFieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('title', 'ezstring');
$titleFieldCreate->names = array('eng-US' => 'American title field name', 'eng-GB' => 'British title field name');
$titleFieldCreate->descriptions = array('eng-US' => 'American title field description', 'eng-GB' => 'British title field description');
$titleFieldCreate->fieldGroup = 'blog-content';
$titleFieldCreate->position = 1;
$titleFieldCreate->isTranslatable = true;
$titleFieldCreate->isRequired = true;
$titleFieldCreate->isInfoCollector = false;
$titleFieldCreate->isSearchable = true;
$titleFieldCreate->defaultValue = 'New text line';
//$titleFieldCreate->validators
//$titleFieldCreate->fieldSettings
$typeCreateStruct->addFieldDefinition($titleFieldCreate);
$type1 = $contentTypeService->createContentType($typeCreateStruct, array($group));
$contentTypeService->publishContentTypeDraft($type1);
$typeCreateStruct->identifier = 'test-type-2';
$typeCreateStruct->remoteId = 'test-remoteid-2';
$type2 = $contentTypeService->createContentType($typeCreateStruct, array($group));
$contentTypeService->publishContentTypeDraft($type2);
/* BEGIN: Use Case */
$loadedTypes = $contentTypeService->loadContentTypes($group);
/* END: Use Case */
$this->assertInternalType('array', $loadedTypes);
return $loadedTypes;
}