Skip to content

Commit

Permalink
WIP: Part III (Playground test)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nattfarinn committed Nov 28, 2023
1 parent 6cdb859 commit 90d2fe4
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions tests/integration/Core/Repository/ProofOfConceptTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

Check warning on line 1 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.0)

Found violation(s) of type: no_unused_imports

Check warning on line 1 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.0)

Found violation(s) of type: single_blank_line_before_namespace

Check warning on line 1 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.0)

Found violation(s) of type: header_comment

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace Ibexa\Tests\Integration\Core\Repository;

use Ibexa\Contracts\Core\Repository\ContentService;
use Ibexa\Contracts\Core\Repository\ContentTypeService;
use Ibexa\Contracts\Core\Repository\LanguageService;
use Ibexa\Core\Repository\Values\Content\ContentUpdateStruct;

class ProofOfConceptTest extends BaseContentServiceTest
{
private const ENG_US = 'eng-US';
private const ENG_GB = 'eng-GB';
private const GER_DE = 'ger-DE';

Check failure on line 18 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (7.4)

Constant Ibexa\Tests\Integration\Core\Repository\ProofOfConceptTest::GER_DE is unused.

Check failure on line 18 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (8.0)

Constant Ibexa\Tests\Integration\Core\Repository\ProofOfConceptTest::GER_DE is unused.

Check failure on line 18 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (8.1)

Constant Ibexa\Tests\Integration\Core\Repository\ProofOfConceptTest::GER_DE is unused.

private ContentService $contentService;

private ContentTypeService $contentTypeService;

private LanguageService $languageService;

Check failure on line 24 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (7.4)

Property Ibexa\Tests\Integration\Core\Repository\ProofOfConceptTest::$languageService is never read, only written.

Check failure on line 24 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (8.0)

Property Ibexa\Tests\Integration\Core\Repository\ProofOfConceptTest::$languageService is never read, only written.

Check failure on line 24 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (8.1)

Property Ibexa\Tests\Integration\Core\Repository\ProofOfConceptTest::$languageService is never read, only written.

public function setUp(): void
{
parent::setUp();

$this->contentService = $this->getRepository()->getContentService();
$this->contentTypeService = $this->getRepository()->getContentTypeService();
$this->languageService = $this->getRepository()->getContentLanguageService();
}

public function testProofOfConcept()

Check failure on line 35 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (7.4)

Method Ibexa\Tests\Integration\Core\Repository\ProofOfConceptTest::testProofOfConcept() has no return type specified.

Check failure on line 35 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (8.0)

Method Ibexa\Tests\Integration\Core\Repository\ProofOfConceptTest::testProofOfConcept() has no return type specified.

Check failure on line 35 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (8.1)

Method Ibexa\Tests\Integration\Core\Repository\ProofOfConceptTest::testProofOfConcept() has no return type specified.
{
$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();

Check failure on line 77 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (7.4)

Property Ibexa\Contracts\Core\Repository\Values\Content\ContentUpdateStruct::$fields (array<Ibexa\Contracts\Core\Repository\Values\Content\Field>) does not accept iterable<Ibexa\Contracts\Core\Repository\Values\Content\Field>.

Check failure on line 77 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (8.0)

Property Ibexa\Contracts\Core\Repository\Values\Content\ContentUpdateStruct::$fields (array<Ibexa\Contracts\Core\Repository\Values\Content\Field>) does not accept iterable<Ibexa\Contracts\Core\Repository\Values\Content\Field>.

Check failure on line 77 in tests/integration/Core/Repository/ProofOfConceptTest.php

View workflow job for this annotation

GitHub Actions / Unit tests & SQLite integration tests (8.1)

Property Ibexa\Contracts\Core\Repository\Values\Content\ContentUpdateStruct::$fields (array<Ibexa\Contracts\Core\Repository\Values\Content\Field>) does not accept iterable<Ibexa\Contracts\Core\Repository\Values\Content\Field>.
$contentUpdateStruct->setField('name', 'PoC GB', self::ENG_GB);
$this->contentService->updateContent($contentDraft->versionInfo, $contentUpdateStruct);
$content = $this->contentService->publishVersion($contentDraft->versionInfo);
}
}

0 comments on commit 90d2fe4

Please sign in to comment.