diff --git a/tests/integration/Core/Repository/ProofOfConceptTest.php b/tests/integration/Core/Repository/ProofOfConceptTest.php new file mode 100644 index 0000000000..bc9de328e2 --- /dev/null +++ b/tests/integration/Core/Repository/ProofOfConceptTest.php @@ -0,0 +1,82 @@ +contentService = $this->getRepository()->getContentService(); + $this->contentTypeService = $this->getRepository()->getContentTypeService(); + $this->languageService = $this->getRepository()->getContentLanguageService(); + } + + public function testProofOfConcept() + { + $contentType = $this->contentTypeService->loadContentTypeByIdentifier('folder'); + + // Create content + $contentCreateStruct = $this->contentService->newContentCreateStruct($contentType, self::ENG_US); + $contentCreateStruct->setField('name', 'PoC', self::ENG_US); + $contentCreateStruct->setField('short_name', 'PoC', self::ENG_US); + $contentDraft = $this->contentService->createContent($contentCreateStruct); + $content = $this->contentService->publishVersion($contentDraft->getVersionInfo()); + + // Update content type definition + $contentTypeDraft = $this->contentTypeService->createContentTypeDraft($contentType); + $fieldDefCreateStruct = $this->contentTypeService->newFieldDefinitionCreateStruct( + 'poc_field', + 'ezstring' + ); + $fieldDefCreateStruct->names = [self::ENG_US => 'PoC Field']; + $fieldDefCreateStruct->descriptions = [self::ENG_US => 'PoC Field']; + $fieldDefCreateStruct->fieldGroup = 'content'; + $fieldDefCreateStruct->position = 2; + $fieldDefCreateStruct->isTranslatable = true; + $fieldDefCreateStruct->isRequired = true; + $fieldDefCreateStruct->isInfoCollector = false; + $fieldDefCreateStruct->validatorConfiguration = [ + 'StringLengthValidator' => [ + 'minStringLength' => 0, + 'maxStringLength' => 0, + ], + ]; + $fieldDefCreateStruct->fieldSettings = []; + $fieldDefCreateStruct->isSearchable = true; + $fieldDefCreateStruct->defaultValue = 'Default PoC Value'; + + $this->contentTypeService->addFieldDefinition($contentTypeDraft, $fieldDefCreateStruct); + $this->contentTypeService->publishContentTypeDraft($contentTypeDraft); + $contentType = $this->contentTypeService->loadContentType($contentTypeDraft->id); + + // Translate content + $contentDraft = $this->contentService->createContentDraft($content->contentInfo); + $contentUpdateStruct = $this->contentService->newContentUpdateStruct(); + $contentUpdateStruct->initialLanguageCode = self::ENG_GB; + $contentUpdateStruct->fields = $contentDraft->getFields(); + $contentUpdateStruct->setField('name', 'PoC GB', self::ENG_GB); + $this->contentService->updateContent($contentDraft->versionInfo, $contentUpdateStruct); + $content = $this->contentService->publishVersion($contentDraft->versionInfo); + } +}