eZ\Publish\Core\Repository\Tests\Service\Integration\ContentTypeBase::testCreateContentTypeThrowsInvalidArgumentExceptionDuplicateFieldDefinitionIdentifier PHP Method

testCreateContentTypeThrowsInvalidArgumentExceptionDuplicateFieldDefinitionIdentifier() public method

Test for the createContentTypeGroup() method.
    public function testCreateContentTypeThrowsInvalidArgumentExceptionDuplicateFieldDefinitionIdentifier()
    {
        /* BEGIN: Use Case */
        $contentTypeService = $this->repository->getContentTypeService();
        $typeCreateStruct = $contentTypeService->newContentTypeCreateStruct('new-type');
        $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 = 'new-remoteid';
        $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->validatorConfiguration = array('StringLengthValidator' => array('maxStringLength' => 128));
        //$titleFieldCreate->fieldSettings
        $typeCreateStruct->addFieldDefinition($titleFieldCreate);
        $typeCreateStruct->addFieldDefinition(clone $titleFieldCreate);
        $groups = $this->createGroups();
        // Throws an exception because two field definition create structs have the same identifier
        $type = $contentTypeService->createContentType($typeCreateStruct, $groups);
        /* END: Use Case */
    }
ContentTypeBase