diff --git a/composer.json b/composer.json index a355ab0750..201a821125 100644 --- a/composer.json +++ b/composer.json @@ -64,10 +64,12 @@ "require-dev": { "behat/behat": "^3.6.1", "composer-runtime-api": "^2.0", + "dama/doctrine-test-bundle": "^6.7", "jenner/simple_fork": "^1.2", "friends-of-behat/mink-extension": "^2.4", "ibexa/ci-scripts": "^0.2@dev", "ibexa/code-style": "^1.0", + "ibexa/test-core": "~4.6.x-dev", "phpunit/phpunit": "^8.2", "matthiasnoback/symfony-dependency-injection-test": "^4.1", "symfony/phpunit-bridge": "^5.4", @@ -145,7 +147,8 @@ "phpstan": "phpstan analyse", "integration": [ "Composer\\Config::disableProcessTimeout", - "phpunit -c phpunit-integration-legacy.xml" + "phpunit -c phpunit-integration-legacy.xml", + "phpunit -c phpunit-integration.xml" ], "test-integration-solr": "phpunit -c phpunit-integration-legacy-solr.xml", "test": [ diff --git a/dependencies.json b/dependencies.json new file mode 100644 index 0000000000..e697754065 --- /dev/null +++ b/dependencies.json @@ -0,0 +1,11 @@ +{ + "recipesEndpoint": "", + "packages": [ + { + "requirement": "dev-kernel-test-bootstrap-v2 as 4.6.x-dev", + "repositoryUrl": "https://github.com/ibexa/test-core.git", + "package": "ibexa/test-core", + "shouldBeAddedAsVCS": false + } + ] +} diff --git a/phpunit-integration-legacy.xml b/phpunit-integration-legacy.xml index 5a608b168f..3ff2a56d31 100644 --- a/phpunit-integration-legacy.xml +++ b/phpunit-integration-legacy.xml @@ -24,6 +24,23 @@ tests/integration/Core + + tests/integration/Core/BasicKernelTest.php + tests/integration/Core/Repository/SerializationTest.php + tests/integration/Core/Repository/ContentTypeService/FindContentTypesTest.php + tests/integration/Core/Repository/ContentService/CopyNonTranslatableFieldsFromPublishedVersionTest.php + tests/integration/Core/Persistence/Legacy/BookmarkHandlerTest.php + tests/integration/Core/Repository/ContentService/CopyTranslationsFromPublishedVersionTest.php + tests/integration/Core/Repository/URLAliasService/UrlAliasLookupTest.php + tests/integration/Core/Repository/ContentService/ContentUpdateAfterAddingFieldDefinitionTest.php + tests/integration/Core/Repository/ContentService/UpdateContentTest.php + tests/integration/Core/Repository/ContentService/ImageAssetTest.php + tests/integration/Core/Repository/ContentService/LoadVersionInfoTest.php + tests/integration/Core/Repository/ContentService/DeleteContentTest.php + tests/integration/Core/Repository/ContentService/MaxLanguagesContentServiceTest.php + tests/integration/Core/Repository/SearchServiceBookmarkTest.php + tests/integration/Core/Repository/SearchServiceContentNameTest.php + tests/integration/Core/Repository/SearchServiceImageTest.php tests/integration/Debug diff --git a/phpunit-integration.xml b/phpunit-integration.xml new file mode 100644 index 0000000000..352961bb2b --- /dev/null +++ b/phpunit-integration.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + tests/integration/Core/BasicKernelTest.php + tests/integration/Core/Repository/SerializationTest.php + tests/integration/Core/Repository/ContentTypeService/FindContentTypesTest.php + tests/integration/Core/Repository/ContentService/CopyNonTranslatableFieldsFromPublishedVersionTest.php + tests/integration/Core/Persistence/Legacy/BookmarkHandlerTest.php + tests/integration/Core/Repository/ContentService/CopyTranslationsFromPublishedVersionTest.php + tests/integration/Core/Repository/URLAliasService/UrlAliasLookupTest.php + tests/integration/Core/Repository/ContentService/ContentUpdateAfterAddingFieldDefinitionTest.php + tests/integration/Core/Repository/ContentService/UpdateContentTest.php + tests/integration/Core/Repository/ContentService/ImageAssetTest.php + tests/integration/Core/Repository/ContentService/LoadVersionInfoTest.php + tests/integration/Core/Repository/ContentService/DeleteContentTest.php + tests/integration/Core/Repository/ContentService/MaxLanguagesContentServiceTest.php + tests/integration/Core/Repository/SearchServiceBookmarkTest.php + tests/integration/Core/Repository/SearchServiceContentNameTest.php + tests/integration/Core/Repository/SearchServiceImageTest.php + + + + + + diff --git a/tests/integration/Core/BasicKernelTest.php b/tests/integration/Core/BasicKernelTest.php index 15ec36bbb7..37a5e49910 100644 --- a/tests/integration/Core/BasicKernelTest.php +++ b/tests/integration/Core/BasicKernelTest.php @@ -9,24 +9,19 @@ namespace Ibexa\Tests\Integration\Core; use Ibexa\Contracts\Core\Repository\Repository; -use Ibexa\Contracts\Core\Test\IbexaKernelTestCase; +use Ibexa\Contracts\Test\Core\IbexaKernelTestCase; /** + * Schema and fixtures are imported once, before the suite runs, by tests/integration/bootstrap.php — + * this test only needs to boot the kernel. + * * @coversNothing */ final class BasicKernelTest extends IbexaKernelTestCase { - protected function setUp(): void - { - self::bootKernel(); - - self::loadSchema(); - self::loadFixtures(); - } - public function testBasicKernelCompiles(): void { - self::getServiceByClassName(Repository::class); + $this->getIbexaTestCore()->getServiceByClassName(Repository::class); $this->expectNotToPerformAssertions(); } diff --git a/tests/integration/Core/Persistence/Legacy/BookmarkHandlerTest.php b/tests/integration/Core/Persistence/Legacy/BookmarkHandlerTest.php index 85239fbc36..bb8aedc12c 100644 --- a/tests/integration/Core/Persistence/Legacy/BookmarkHandlerTest.php +++ b/tests/integration/Core/Persistence/Legacy/BookmarkHandlerTest.php @@ -29,7 +29,7 @@ protected function setUp(): void { parent::setUp(); - $this->handler = self::getServiceByClassName(Handler::class); + $this->handler = $this->getIbexaTestCore()->getServiceByClassName(Handler::class); $this->bookmarkHandler = $this->handler->bookmarkHandler(); } diff --git a/tests/integration/Core/Repository/ContentService/ContentUpdateAfterAddingFieldDefinitionTest.php b/tests/integration/Core/Repository/ContentService/ContentUpdateAfterAddingFieldDefinitionTest.php index 10eca3062f..4f99b8e2b8 100644 --- a/tests/integration/Core/Repository/ContentService/ContentUpdateAfterAddingFieldDefinitionTest.php +++ b/tests/integration/Core/Repository/ContentService/ContentUpdateAfterAddingFieldDefinitionTest.php @@ -21,8 +21,8 @@ final class ContentUpdateAfterAddingFieldDefinitionTest extends RepositoryTestCa */ public function testUpdateFields(): void { - $contentService = self::getContentService(); - $contentTypeService = self::getContentTypeService(); + $contentService = $this->getIbexaTestCore()->getContentService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); // Create new ContentType $fieldDefCreateStruct = $this->createFieldDefinitionStruct('name', 'Name', true); @@ -60,7 +60,7 @@ public function testUpdateFields(): void private function createFieldDefinitionStruct(string $identifier, string $name, bool $isTranslatable): FieldDefinitionCreateStruct { - $contentTypeService = self::getContentTypeService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); $fieldDefCreateStruct = $contentTypeService->newFieldDefinitionCreateStruct( $identifier, @@ -78,7 +78,7 @@ private function createFieldDefinitionStruct(string $identifier, string $name, b private function createTypeCreateStruct(): ContentTypeCreateStruct { - $contentTypeService = self::getContentTypeService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); $typeCreateStruct = $contentTypeService->newContentTypeCreateStruct('multi_lang_drafts'); $typeCreateStruct->mainLanguageCode = 'eng-US'; $typeCreateStruct->names = ['eng-US' => 'Multi lang drafts']; @@ -91,9 +91,9 @@ private function createTypeCreateStruct(): ContentTypeCreateStruct */ protected function createNewContent(string $name, array $languages = ['eng-US'], int $parentLocationId = 2): Content { - $contentTypeService = self::getContentTypeService(); - $contentService = self::getContentService(); - $locationService = self::getLocationService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); + $contentService = $this->getIbexaTestCore()->getContentService(); + $locationService = $this->getIbexaTestCore()->getLocationService(); $contentType = $contentTypeService->loadContentTypeByIdentifier('multi_lang_drafts'); $createStruct = $contentService->newContentCreateStruct($contentType, $languages[0]); @@ -113,7 +113,7 @@ protected function createNewContent(string $name, array $languages = ['eng-US'], */ protected function createUpdateStruct(Content $content, string $translatedName, array $languages): ContentUpdateStruct { - $contentService = self::getContentService(); + $contentService = $this->getIbexaTestCore()->getContentService(); $updateStruct = $contentService->newContentUpdateStruct(); $updateStruct->initialLanguageCode = $languages[0]; @@ -135,15 +135,15 @@ protected function createUpdateStruct(Content $content, string $translatedName, protected function createContentDraft(Content $content, string $languageCode): Content { - $contentLanguageService = self::getLanguageService(); + $contentLanguageService = $this->getIbexaTestCore()->getLanguageService(); $language = $contentLanguageService->loadLanguage($languageCode); - return self::getContentService()->createContentDraft($content->contentInfo, null, null, $language); + return $this->getIbexaTestCore()->getContentService()->createContentDraft($content->contentInfo, null, null, $language); } protected function updateContent(Content $draft, ContentUpdateStruct $updateStruct): Content { - return self::getContentService()->updateContent($draft->versionInfo, $updateStruct); + return $this->getIbexaTestCore()->getContentService()->updateContent($draft->versionInfo, $updateStruct); } } diff --git a/tests/integration/Core/Repository/ContentService/CopyNonTranslatableFieldsFromPublishedVersionTest.php b/tests/integration/Core/Repository/ContentService/CopyNonTranslatableFieldsFromPublishedVersionTest.php index 92cd4b8e06..54d2b45588 100644 --- a/tests/integration/Core/Repository/ContentService/CopyNonTranslatableFieldsFromPublishedVersionTest.php +++ b/tests/integration/Core/Repository/ContentService/CopyNonTranslatableFieldsFromPublishedVersionTest.php @@ -31,7 +31,7 @@ public function testCopyNonTranslatableFieldsFromPublishedVersionToDraft(): void { $this->createNonTranslatableContentType(); - $contentService = self::getContentService(); + $contentService = $this->getIbexaTestCore()->getContentService(); // Creating start content in eng-US language $contentDraft = $this->createEngDraft(); @@ -81,7 +81,7 @@ public function testCopyNonTranslatableFieldsTwoParallelDrafts(): void { $this->createNonTranslatableContentType(); - $contentService = self::getContentService(); + $contentService = $this->getIbexaTestCore()->getContentService(); // Creating start content in eng-US language $contentDraft = $this->createEngDraft(); @@ -124,7 +124,7 @@ public function testCopyNonTranslatableFieldsOverridesNonMainLanguageDrafts(): v { $this->createNonTranslatableContentType(); - $contentService = self::getContentService(); + $contentService = $this->getIbexaTestCore()->getContentService(); // Creating start content in eng-US language $contentDraft = $this->createEngDraft(); @@ -167,9 +167,9 @@ public function testCopyNonTranslatableFieldsOverridesNonMainLanguageDrafts(): v private function createEngDraft(): Content { - $contentService = self::getContentService(); - $contentTypeService = self::getContentTypeService(); - $locationService = self::getLocationService(); + $contentService = $this->getIbexaTestCore()->getContentService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); + $locationService = $this->getIbexaTestCore()->getLocationService(); $contentType = $contentTypeService->loadContentTypeByIdentifier(self::CONTENT_TYPE_IDENTIFIER); $mainLanguageCode = self::ENG_US; @@ -187,8 +187,8 @@ private function createEngDraft(): Content private function createNonTranslatableContentType(): void { - $permissionResolver = self::getPermissionResolver(); - $contentTypeService = self::getContentTypeService(); + $permissionResolver = $this->getIbexaTestCore()->getPermissionResolver(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); $typeCreate = $contentTypeService->newContentTypeCreateStruct(self::CONTENT_TYPE_IDENTIFIER); @@ -245,7 +245,7 @@ private function buildFieldDefinitionCreateStructForNonTranslatableContentType( bool $isRequired, ?string $defaultValue = null ): FieldDefinitionCreateStruct { - $contentTypeService = self::getContentTypeService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); $fieldDefinitionCreateStruct = $contentTypeService->newFieldDefinitionCreateStruct( $fieldIdentifier, diff --git a/tests/integration/Core/Repository/ContentService/CopyTranslationsFromPublishedVersionTest.php b/tests/integration/Core/Repository/ContentService/CopyTranslationsFromPublishedVersionTest.php index da95b1dee9..7a0c553d97 100644 --- a/tests/integration/Core/Repository/ContentService/CopyTranslationsFromPublishedVersionTest.php +++ b/tests/integration/Core/Repository/ContentService/CopyTranslationsFromPublishedVersionTest.php @@ -32,9 +32,9 @@ public function testCopyTranslationsFromPublishedVersionCopiesEmptyValues(): voi { $this->createContentType(); - $contentService = self::getContentService(); - $contentTypeService = self::getContentTypeService(); - $locationService = self::getLocationService(); + $contentService = $this->getIbexaTestCore()->getContentService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); + $locationService = $this->getIbexaTestCore()->getLocationService(); // Creating and publishing content in eng-GB language $contentType = $contentTypeService->loadContentTypeByIdentifier(self::CONTENT_TYPE_IDENTIFIER); @@ -86,8 +86,8 @@ public function testCopyTranslationsFromPublishedVersionCopiesEmptyValues(): voi private function createContentType(): void { - $permissionResolver = self::getPermissionResolver(); - $contentTypeService = self::getContentTypeService(); + $permissionResolver = $this->getIbexaTestCore()->getPermissionResolver(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); $typeCreate = $contentTypeService->newContentTypeCreateStruct(self::CONTENT_TYPE_IDENTIFIER); diff --git a/tests/integration/Core/Repository/ContentService/DeleteContentTest.php b/tests/integration/Core/Repository/ContentService/DeleteContentTest.php index e1dd1faf7a..7ee3e023d3 100644 --- a/tests/integration/Core/Repository/ContentService/DeleteContentTest.php +++ b/tests/integration/Core/Repository/ContentService/DeleteContentTest.php @@ -8,6 +8,7 @@ namespace Ibexa\Tests\Integration\Core\Repository\ContentService; +use Ibexa\Contracts\Core\Repository\TrashService; use Ibexa\Contracts\Core\Repository\Values\Content\Content; use Ibexa\Tests\Integration\Core\RepositoryTestCase; use PHPUnit\Framework\Assert; @@ -22,7 +23,7 @@ final class DeleteContentTest extends RepositoryTestCase */ public function testDeleteContentDeletesChildrenDrafts(): void { - $contentService = self::getContentService(); + $contentService = $this->getIbexaTestCore()->getContentService(); [$folder, $draft1, $draft2, $draft3, $draftSecondDepth] = $this->prepareContentStructure(); @@ -43,15 +44,15 @@ public function testDeleteContentDeletesChildrenDrafts(): void */ public function testTrashLocationDeletesChildrenDrafts(): void { - $trashService = self::getTrashService(); - $contentService = self::getContentService(); + $trashService = $this->getIbexaTestCore()->getServiceByClassName(TrashService::class); + $contentService = $this->getIbexaTestCore()->getContentService(); [$folder, $draft1, $draft2, $draft3, $draftSecondDepth] = $this->prepareContentStructure(); $folderMainLocationId = $folder->getVersionInfo()->getContentInfo()->getMainLocationId(); Assert::assertIsNumeric($folderMainLocationId); - $locationToTrash = self::getLocationService()->loadLocation($folderMainLocationId); + $locationToTrash = $this->getIbexaTestCore()->getLocationService()->loadLocation($folderMainLocationId); $trashService->trash($locationToTrash); diff --git a/tests/integration/Core/Repository/ContentService/ImageAssetTest.php b/tests/integration/Core/Repository/ContentService/ImageAssetTest.php index 9184b32d45..33c8137bcf 100644 --- a/tests/integration/Core/Repository/ContentService/ImageAssetTest.php +++ b/tests/integration/Core/Repository/ContentService/ImageAssetTest.php @@ -26,8 +26,8 @@ protected function setUp(): void { parent::setUp(); - $this->contentService = self::getContentService(); - $this->contentTypeService = self::getContentTypeService(); + $this->contentService = $this->getIbexaTestCore()->getContentService(); + $this->contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); } public function testAssetRelationIsRemoved(): void diff --git a/tests/integration/Core/Repository/ContentService/LoadVersionInfoTest.php b/tests/integration/Core/Repository/ContentService/LoadVersionInfoTest.php index 026d6f0e08..97fc6e5316 100644 --- a/tests/integration/Core/Repository/ContentService/LoadVersionInfoTest.php +++ b/tests/integration/Core/Repository/ContentService/LoadVersionInfoTest.php @@ -20,7 +20,7 @@ final class LoadVersionInfoTest extends RepositoryTestCase */ public function testLoadVersionInfoListByContentInfo(): void { - $contentService = self::getContentService(); + $contentService = $this->getIbexaTestCore()->getContentService(); $folder1 = $this->createFolder(['eng-GB' => 'Folder1'], 2); $folder2 = $this->createFolder(['eng-GB' => 'Folder2'], 2); @@ -45,8 +45,8 @@ public function testLoadVersionInfoListByContentInfo(): void public function testLoadVersionInfoListByContentInfoForTopLevelNode(): void { - $contentService = self::getContentService(); - $locationService = self::getLocationService(); + $contentService = $this->getIbexaTestCore()->getContentService(); + $locationService = $this->getIbexaTestCore()->getLocationService(); $location = $locationService->loadLocation(1); diff --git a/tests/integration/Core/Repository/ContentService/MaxLanguagesContentServiceTest.php b/tests/integration/Core/Repository/ContentService/MaxLanguagesContentServiceTest.php index 3fb4b8d4aa..0c474d28a8 100644 --- a/tests/integration/Core/Repository/ContentService/MaxLanguagesContentServiceTest.php +++ b/tests/integration/Core/Repository/ContentService/MaxLanguagesContentServiceTest.php @@ -61,7 +61,7 @@ public function testCreateContent(): void */ private function prepareMaxLanguages(): void { - $languageService = self::getLanguageService(); + $languageService = $this->getIbexaTestCore()->getLanguageService(); foreach (self::$languagesRawList as $languageData) { $languageCreateStruct = $languageService->newLanguageCreateStruct(); diff --git a/tests/integration/Core/Repository/ContentService/UpdateContentTest.php b/tests/integration/Core/Repository/ContentService/UpdateContentTest.php index 0dd3f900f6..42d3471d4f 100644 --- a/tests/integration/Core/Repository/ContentService/UpdateContentTest.php +++ b/tests/integration/Core/Repository/ContentService/UpdateContentTest.php @@ -25,9 +25,9 @@ final class UpdateContentTest extends RepositoryTestCase */ public function testUpdateContentHavingPrivateRelation(): void { - $sectionService = self::getSectionService(); - $contentService = self::getContentService(); - $permissionResolver = self::getPermissionResolver(); + $sectionService = $this->getIbexaTestCore()->getSectionService(); + $contentService = $this->getIbexaTestCore()->getContentService(); + $permissionResolver = $this->getIbexaTestCore()->getPermissionResolver(); $this->addRelationFieldToFolderContentType(); @@ -46,7 +46,7 @@ public function testUpdateContentHavingPrivateRelation(): void $folder = $this->publishVersionWithoutChanges($folder->getContentInfo()); // Read relations & check if count($relations) is unchanged - self::setAdministratorUser(); + $this->getIbexaTestCore()->setAdministratorUser(); $relations = $contentService->loadRelations($folder->getVersionInfo()); if ($relations instanceof \Traversable) { $relations = iterator_to_array($relations); @@ -59,7 +59,7 @@ public function testUpdateContentHavingPrivateRelation(): void */ private function addRelationFieldToFolderContentType(): void { - $contentTypeService = self::getContentTypeService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); $folderType = $contentTypeService->loadContentTypeByIdentifier('folder'); $folderTypeDraft = $contentTypeService->createContentTypeDraft($folderType); @@ -78,7 +78,7 @@ private function addRelationFieldToFolderContentType(): void */ private function createPrivateSection(): Section { - $sectionService = self::getSectionService(); + $sectionService = $this->getIbexaTestCore()->getSectionService(); $sectionCreateStruct = $sectionService->newSectionCreateStruct(); $sectionCreateStruct->identifier = 'private'; @@ -94,7 +94,7 @@ private function createPrivateSection(): Section */ private function createFolderWithRelations(array $relationListTarget): Content { - $contentService = self::getContentService(); + $contentService = $this->getIbexaTestCore()->getContentService(); $folder = $this->createFolder(['eng-GB' => 'Folder with private relation'], 2); $folderDraft = $contentService->createContentDraft($folder->getContentInfo()); @@ -114,8 +114,8 @@ private function createFolderWithRelations(array $relationListTarget): Content */ private function assignToUserRoleWithStandardSectionLimitation(User $user): void { - $sectionService = self::getSectionService(); - $roleService = self::getRoleService(); + $sectionService = $this->getIbexaTestCore()->getSectionService(); + $roleService = $this->getIbexaTestCore()->getRoleService(); $roleCreateStruct = $roleService->newRoleCreateStruct('limited_access'); $roleCreateStruct->addPolicy($roleService->newPolicyCreateStruct('*', '*')); @@ -147,7 +147,7 @@ private function createUserWithNoAccessToPrivateSection(): User */ private function publishVersionWithoutChanges(ContentInfo $contentInfo): Content { - $contentService = self::getContentService(); + $contentService = $this->getIbexaTestCore()->getContentService(); $folderDraft = $contentService->createContentDraft($contentInfo); $folderUpdateStruct = $contentService->newContentUpdateStruct(); diff --git a/tests/integration/Core/Repository/ContentTypeService/FindContentTypesTest.php b/tests/integration/Core/Repository/ContentTypeService/FindContentTypesTest.php index ec896e9855..e374a71af6 100644 --- a/tests/integration/Core/Repository/ContentTypeService/FindContentTypesTest.php +++ b/tests/integration/Core/Repository/ContentTypeService/FindContentTypesTest.php @@ -21,16 +21,21 @@ use Ibexa\Contracts\Core\Repository\Values\ContentType\Query\Criterion\LogicalOr; use Ibexa\Contracts\Core\Repository\Values\ContentType\Query\SortClause\Identifier; use Ibexa\Contracts\Core\Repository\Values\ContentType\Query\SortClause\Name; -use Ibexa\Tests\Integration\Core\RepositoryTestCase; +use Ibexa\Contracts\Test\Core\IbexaKernelTestCase; /** * @covers \Ibexa\Contracts\Core\Repository\ContentTypeService */ -final class FindContentTypesTest extends RepositoryTestCase +final class FindContentTypesTest extends IbexaKernelTestCase { + protected function setUp(): void + { + $this->getIbexaTestCore()->setAdministratorUser(); + } + public function testFindContentTypesWithNullQueryFinds25Results(): void { - $contentTypeService = self::getContentTypeService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); $contentTypes = $contentTypeService->findContentTypes(); @@ -47,7 +52,7 @@ public function testFindContentTypesWithNullQueryFinds25Results(): void */ public function testFindContentTypes(ContentTypeQuery $query, array $expectedIdentifiers): void { - $contentTypeService = self::getContentTypeService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); $contentTypes = $contentTypeService->findContentTypes($query); $identifiers = array_map( @@ -61,7 +66,7 @@ public function testFindContentTypes(ContentTypeQuery $query, array $expectedIde public function testFindContentTypesAscSortedByIdentifier(): void { - $contentTypeService = self::getContentTypeService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); $contentTypes = $contentTypeService->findContentTypes( new ContentTypeQuery( @@ -80,7 +85,7 @@ public function testFindContentTypesAscSortedByIdentifier(): void public function testFindContentTypesAscSortedByName(): void { - $contentTypeService = self::getContentTypeService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); $contentTypes = $contentTypeService->findContentTypes( new ContentTypeQuery( @@ -100,7 +105,7 @@ public function testFindContentTypesAscSortedByName(): void public function testPagination(): void { - $contentTypeService = self::getContentTypeService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); $collectedContentTypeIDs = []; $pageSize = 10; @@ -126,7 +131,7 @@ public function testPagination(): void public function testFindContentTypesContainingFieldDefinitions(): void { - $contentTypeService = self::getContentTypeService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); $folderContentType = $contentTypeService->loadContentTypeByIdentifier('folder'); $fieldDefinitionToInclude = null; diff --git a/tests/integration/Core/Repository/SearchServiceBookmarkTest.php b/tests/integration/Core/Repository/SearchServiceBookmarkTest.php index 6e21ee2e3b..89e00fe605 100644 --- a/tests/integration/Core/Repository/SearchServiceBookmarkTest.php +++ b/tests/integration/Core/Repository/SearchServiceBookmarkTest.php @@ -171,7 +171,7 @@ private function assertExpectedSearchHits( array $expectedRemoteIds, LocationQuery $query ): void { - $searchHits = self::getSearchService()->findLocations($query); + $searchHits = $this->getIbexaTestCore()->getSearchService()->findLocations($query); self::assertSame($expectedCount, $searchHits->totalCount); @@ -229,12 +229,13 @@ private function addLocationToBookmark(Location $location): void private function loadMediaFolderLocation(): Location { return $this + ->getIbexaTestCore() ->getLocationService() ->loadLocation(self::MEDIA_CONTENT_TYPE_ID); } private function getBookmarkService(): BookmarkService { - return self::getServiceByClassName(BookmarkService::class); + return $this->getIbexaTestCore()->getServiceByClassName(BookmarkService::class); } } diff --git a/tests/integration/Core/Repository/SearchServiceContentNameTest.php b/tests/integration/Core/Repository/SearchServiceContentNameTest.php index b333212898..3b781ee59a 100644 --- a/tests/integration/Core/Repository/SearchServiceContentNameTest.php +++ b/tests/integration/Core/Repository/SearchServiceContentNameTest.php @@ -75,7 +75,7 @@ public function testCriterionFindAllContentItems(): void self::assertSame( self::TOTAL_COUNT, - self::getSearchService()->findContent($query)->totalCount + $this->getIbexaTestCore()->getSearchService()->findContent($query)->totalCount ); } @@ -93,7 +93,7 @@ public function testCriterion( array $expectedContentItemTitles, int $expectedCount ): void { - $result = self::getSearchService()->findContent( + $result = $this->getIbexaTestCore()->getSearchService()->findContent( $this->createQuery($criterion), $this->getLanguageFilter($languageCode) ); @@ -239,7 +239,7 @@ private function createContent( string $mainLanguageCode, array $translations ): Content { - $contentService = self::getContentService(); + $contentService = $this->getIbexaTestCore()->getContentService(); $createStruct = $contentService->newContentCreateStruct( $this->loadContentType('article'), $mainLanguageCode @@ -265,7 +265,7 @@ private function createContent( */ private function loadContentType(string $contentTypeIdentifier): ContentType { - return self::getContentTypeService() + return $this->getIbexaTestCore()->getContentTypeService() ->loadContentTypeByIdentifier($contentTypeIdentifier); } diff --git a/tests/integration/Core/Repository/SearchServiceImageTest.php b/tests/integration/Core/Repository/SearchServiceImageTest.php index 8c8de7c906..7b09210a20 100644 --- a/tests/integration/Core/Repository/SearchServiceImageTest.php +++ b/tests/integration/Core/Repository/SearchServiceImageTest.php @@ -58,7 +58,7 @@ public function testCriterion( ] ); - $searchHits = self::getSearchService()->findContent($query); + $searchHits = $this->getIbexaTestCore()->getSearchService()->findContent($query); self::assertSame( $expectedCount, @@ -349,7 +349,7 @@ private function createContentImage( string $path, string $fileName ): void { - $contentCreateStruct = self::getContentService()->newContentCreateStruct( + $contentCreateStruct = $this->getIbexaTestCore()->getContentService()->newContentCreateStruct( $contentType, 'eng-GB' ); @@ -361,7 +361,7 @@ private function createContentImage( $contentCreateStruct->setField('name', new TextValue('Image'), 'eng-GB'); $contentCreateStruct->setField('image', $imageValue, 'eng-GB'); - $contentService = self::getContentService(); + $contentService = $this->getIbexaTestCore()->getContentService(); $contentService->publishVersion( $contentService ->createContent($contentCreateStruct) @@ -371,7 +371,7 @@ private function createContentImage( private function loadContentTypeImage(): ContentType { - $imageContentType = self::getContentTypeService()->loadContentTypeByIdentifier(self::IMAGE_CONTENT_TYPE); + $imageContentType = $this->getIbexaTestCore()->getContentTypeService()->loadContentTypeByIdentifier(self::IMAGE_CONTENT_TYPE); $this->ensureImageFieldTypeIsSearchable($imageContentType); @@ -389,7 +389,7 @@ private function ensureImageFieldTypeIsSearchable(ContentType $contentType): voi } $this->setFieldTypeAsSearchable( - self::getContentTypeService()->createContentTypeDraft($contentType), + $this->getIbexaTestCore()->getContentTypeService()->createContentTypeDraft($contentType), $fieldDefinition ); } @@ -403,11 +403,11 @@ private function setFieldTypeAsSearchable( ContentTypeDraft $contentTypeDraft, FieldDefinition $fieldDefinition ): void { - $contentTypeService = self::getContentTypeService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); $fieldDefinitionUpdateStruct = $contentTypeService->newFieldDefinitionUpdateStruct(); $fieldDefinitionUpdateStruct->isSearchable = true; - $contentTypeService = self::getContentTypeService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); $contentTypeService->updateFieldDefinition( $contentTypeDraft, $fieldDefinition, diff --git a/tests/integration/Core/Repository/SerializationTest.php b/tests/integration/Core/Repository/SerializationTest.php index 2e65ca6f74..2e44f4aed5 100644 --- a/tests/integration/Core/Repository/SerializationTest.php +++ b/tests/integration/Core/Repository/SerializationTest.php @@ -8,17 +8,22 @@ namespace Ibexa\Tests\Integration\Core\Repository; -use Ibexa\Tests\Integration\Core\RepositoryTestCase; +use Ibexa\Contracts\Test\Core\IbexaKernelTestCase; use Symfony\Component\Serializer\Encoder\JsonEncode; use Symfony\Component\Serializer\SerializerInterface; -final class SerializationTest extends RepositoryTestCase +final class SerializationTest extends IbexaKernelTestCase { + protected function setUp(): void + { + $this->getIbexaTestCore()->setAdministratorUser(); + } + public function testSerialization(): void { $serializer = $this->getContainer()->get(SerializerInterface::class); self::assertInstanceOf(SerializerInterface::class, $serializer); - $contentService = self::getContentService(); + $contentService = $this->getIbexaTestCore()->getContentService(); $user = $contentService->loadContent(14); $field = $user->getField('user_account'); diff --git a/tests/integration/Core/Repository/URLAliasService/UrlAliasLookupTest.php b/tests/integration/Core/Repository/URLAliasService/UrlAliasLookupTest.php index d61140be32..e57ec7fa27 100644 --- a/tests/integration/Core/Repository/URLAliasService/UrlAliasLookupTest.php +++ b/tests/integration/Core/Repository/URLAliasService/UrlAliasLookupTest.php @@ -8,6 +8,7 @@ namespace Ibexa\Tests\Integration\Core\Repository\URLAliasService; +use Ibexa\Contracts\Core\Repository\URLAliasService; use Ibexa\Tests\Integration\Core\RepositoryTestCase; /** @@ -20,7 +21,7 @@ final class UrlAliasLookupTest extends RepositoryTestCase */ public function testLookup(): void { - $urlAliasService = self::getUrlAliasService(); + $urlAliasService = $this->getIbexaTestCore()->getServiceByClassName(URLAliasService::class); $folder = $this->createFolder(['eng-GB' => 'Foo']); $folderMainLocation = $folder->getVersionInfo()->getContentInfo()->getMainLocation(); $urlAlias = $urlAliasService->lookup('/Foo'); diff --git a/tests/integration/Core/RepositoryTestCase.php b/tests/integration/Core/RepositoryTestCase.php index c23c3a5475..c1658498db 100644 --- a/tests/integration/Core/RepositoryTestCase.php +++ b/tests/integration/Core/RepositoryTestCase.php @@ -11,7 +11,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Content; use Ibexa\Contracts\Core\Repository\Values\User\User; use Ibexa\Contracts\Core\Repository\Values\User\UserGroup; -use Ibexa\Contracts\Core\Test\IbexaKernelTestCase; +use Ibexa\Contracts\Test\Core\IbexaKernelTestCase; use InvalidArgumentException; abstract class RepositoryTestCase extends IbexaKernelTestCase @@ -24,12 +24,7 @@ abstract class RepositoryTestCase extends IbexaKernelTestCase protected function setUp(): void { - parent::setUp(); - - self::loadSchema(); - self::loadFixtures(); - - self::setAdministratorUser(); + $this->getIbexaTestCore()->setAdministratorUser(); } /** @@ -39,7 +34,7 @@ protected function setUp(): void */ public function createFolder(array $names, int $parentLocationId = self::CONTENT_TREE_ROOT_ID): Content { - $contentService = self::getContentService(); + $contentService = $this->getIbexaTestCore()->getContentService(); $draft = $this->createFolderDraft($names, $parentLocationId); return $contentService->publishVersion($draft->getVersionInfo()); @@ -54,7 +49,7 @@ public function createFolder(array $names, int $parentLocationId = self::CONTENT */ final protected function createUser(string $login, string $firstName, string $lastName, ?UserGroup $userGroup = null): User { - $userService = self::getUserService(); + $userService = $this->getIbexaTestCore()->getUserService(); if (null === $userGroup) { $userGroup = $userService->loadUserGroupByRemoteId(self::MAIN_USER_GROUP_REMOTE_ID); @@ -87,9 +82,9 @@ public function createFolderDraft(array $names, int $parentLocationId = self::CO throw new InvalidArgumentException(__METHOD__ . ' requires $names to be not empty'); } - $contentService = self::getContentService(); - $contentTypeService = self::getContentTypeService(); - $locationService = self::getLocationService(); + $contentService = $this->getIbexaTestCore()->getContentService(); + $contentTypeService = $this->getIbexaTestCore()->getContentTypeService(); + $locationService = $this->getIbexaTestCore()->getLocationService(); $folderType = $contentTypeService->loadContentTypeByIdentifier(self::CONTENT_TYPE_FOLDER_IDENTIFIER); $mainLanguageCode = array_keys($names)[0]; diff --git a/tests/integration/Core/TestKernel.php b/tests/integration/Core/TestKernel.php new file mode 100644 index 0000000000..0a8866eb4d --- /dev/null +++ b/tests/integration/Core/TestKernel.php @@ -0,0 +1,60 @@ +load(static function (ContainerBuilder $container): void { + $container->setParameter('ibexa.kernel.root_dir', dirname(__DIR__, 3)); + }); + + parent::registerContainerConfiguration($loader); + } + + public function registerBundles(): iterable + { + yield from parent::registerBundles(); + + yield new DAMADoctrineTestBundle(); + } + + protected static function getExposedServicesByClass(): iterable + { + yield from parent::getExposedServicesByClass(); + + yield TrashService::class; + yield BookmarkService::class; + yield Handler::class; + } + + public function getFixtures(): iterable + { + yield new YamlFixture(__DIR__ . '/Repository/_fixtures/Legacy/data/test_data.yaml'); + } +} diff --git a/tests/integration/bootstrap.php b/tests/integration/bootstrap.php new file mode 100644 index 0000000000..f6847a77f6 --- /dev/null +++ b/tests/integration/bootstrap.php @@ -0,0 +1,13 @@ +shutdown();