From 674c3114fec79921b13bcce637055ff5b918bf19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Thu, 20 Aug 2026 17:29:51 +0200 Subject: [PATCH 1/6] Showcase the ibexa/test-core Bootstrapper in BasicKernelTest BasicKernelTest no longer calls self::loadSchema()/self::loadFixtures() per test; tests/integration/bootstrap.php now does it once via the new Bootstrapper class from ibexa/test-core. Moved to its own phpunit-integration.xml since it needs a different KERNEL_CLASS/bootstrap than the rest of the legacy integration suite. --- composer.json | 4 +++- phpunit-integration-legacy.xml | 2 ++ phpunit-integration.xml | 25 ++++++++++++++++++++++ tests/integration/Core/BasicKernelTest.php | 15 +++++-------- tests/integration/bootstrap.php | 13 +++++++++++ 5 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 phpunit-integration.xml create mode 100644 tests/integration/bootstrap.php diff --git a/composer.json b/composer.json index a355ab0750..2bfdb8fea2 100644 --- a/composer.json +++ b/composer.json @@ -68,6 +68,7 @@ "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 +146,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/phpunit-integration-legacy.xml b/phpunit-integration-legacy.xml index 5a608b168f..aee5652434 100644 --- a/phpunit-integration-legacy.xml +++ b/phpunit-integration-legacy.xml @@ -24,6 +24,8 @@ tests/integration/Core + + tests/integration/Core/BasicKernelTest.php tests/integration/Debug diff --git a/phpunit-integration.xml b/phpunit-integration.xml new file mode 100644 index 0000000000..d674f9ad82 --- /dev/null +++ b/phpunit-integration.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + tests/integration/Core/BasicKernelTest.php + + + diff --git a/tests/integration/Core/BasicKernelTest.php b/tests/integration/Core/BasicKernelTest.php index 15ec36bbb7..3d0ef9b711 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; /** + * Showcases the ibexa/test-core Bootstrapper + Hook setup: 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/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(); From ea23153bcc3e0f11ad7e8dc0870fb82f2f2df1c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Thu, 20 Aug 2026 17:29:59 +0200 Subject: [PATCH 2/6] TEMPORARY: Added dependencies.json to test against ibexa/test-core#38 Points CI at the kernel-test-bootstrap-v2 branch that adds the Bootstrapper class this PR depends on, so tests can run before that PR merges. Must be removed before merging. --- dependencies.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 dependencies.json 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 + } + ] +} From 680a6b33a8c865f666fac2ef8fe6e23f8faa2f43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Fri, 21 Aug 2026 23:14:46 +0200 Subject: [PATCH 3/6] Reworded BasicKernelTest docblock to drop "showcase" framing --- tests/integration/Core/BasicKernelTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/Core/BasicKernelTest.php b/tests/integration/Core/BasicKernelTest.php index 3d0ef9b711..37a5e49910 100644 --- a/tests/integration/Core/BasicKernelTest.php +++ b/tests/integration/Core/BasicKernelTest.php @@ -12,8 +12,8 @@ use Ibexa\Contracts\Test\Core\IbexaKernelTestCase; /** - * Showcases the ibexa/test-core Bootstrapper + Hook setup: schema and fixtures are imported once, - * before the suite runs, by tests/integration/bootstrap.php — this test only needs to boot the kernel. + * Schema and fixtures are imported once, before the suite runs, by tests/integration/bootstrap.php — + * this test only needs to boot the kernel. * * @coversNothing */ From 4d43974e9a44a6e1e0b53dd57acdfd7e19b363a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Fri, 21 Aug 2026 23:15:02 +0200 Subject: [PATCH 4/6] Migrated SerializationTest and FindContentTypesTest to the Bootstrapper Both were read-only (no content/user/role mutations), the safe subset of RepositoryTestCase's 16 leaf classes to move off the per-test self::loadSchema()/loadFixtures() pattern without needing per-test transactional isolation first - the other 14 mutate repository data and have nothing (no DAMADoctrineTestBundle or similar) to roll that back between tests today. Added tests/integration/Core/TestKernel.php, overriding getFixtures() to keep loading the same Legacy/data/test_data.yaml fixture set these tests were already calibrated against (25 content types, specific admin user field values, etc.) instead of the shared kernel's own smaller generic default - otherwise their assertions would fail on a mismatched fixture set despite the migration itself being safe. --- phpunit-integration-legacy.xml | 2 ++ phpunit-integration.xml | 4 ++- .../FindContentTypesTest.php | 21 ++++++++++------ .../Core/Repository/SerializationTest.php | 11 +++++--- tests/integration/Core/TestKernel.php | 25 +++++++++++++++++++ 5 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 tests/integration/Core/TestKernel.php diff --git a/phpunit-integration-legacy.xml b/phpunit-integration-legacy.xml index aee5652434..00453ad82d 100644 --- a/phpunit-integration-legacy.xml +++ b/phpunit-integration-legacy.xml @@ -26,6 +26,8 @@ tests/integration/Core tests/integration/Core/BasicKernelTest.php + tests/integration/Core/Repository/SerializationTest.php + tests/integration/Core/Repository/ContentTypeService/FindContentTypesTest.php tests/integration/Debug diff --git a/phpunit-integration.xml b/phpunit-integration.xml index d674f9ad82..3fe71d14b5 100644 --- a/phpunit-integration.xml +++ b/phpunit-integration.xml @@ -14,12 +14,14 @@ - + tests/integration/Core/BasicKernelTest.php + tests/integration/Core/Repository/SerializationTest.php + tests/integration/Core/Repository/ContentTypeService/FindContentTypesTest.php 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/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/TestKernel.php b/tests/integration/Core/TestKernel.php new file mode 100644 index 0000000000..9a9be9bfca --- /dev/null +++ b/tests/integration/Core/TestKernel.php @@ -0,0 +1,25 @@ + Date: Sat, 22 Aug 2026 00:42:58 +0200 Subject: [PATCH 5/6] Added DAMA doctrine-test-bundle to unlock mutating RepositoryTestCase tests Mutating tests couldn't use the Bootstrapper before, since it only imports schema/fixtures once per suite run rather than per test. DAMA wraps each test in a transaction rolled back afterwards, so RepositoryTestCase no longer needs to reimport schema/fixtures in setUp(). TestKernel also needed to set the ibexa.kernel.root_dir container parameter itself: the shared ibexa/test-core kernel has no knowledge of it, so without an override it fell back to the production default (vendor/ibexa/core), breaking TransformationProcessor's .tr/.tr.result fixture paths when running ibexa-core's own suite standalone. --- composer.json | 1 + phpunit-integration-legacy.xml | 13 +++++++ phpunit-integration.xml | 16 +++++++++ tests/integration/Core/RepositoryTestCase.php | 19 ++++------ tests/integration/Core/TestKernel.php | 35 +++++++++++++++++++ 5 files changed, 72 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 2bfdb8fea2..201a821125 100644 --- a/composer.json +++ b/composer.json @@ -64,6 +64,7 @@ "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", diff --git a/phpunit-integration-legacy.xml b/phpunit-integration-legacy.xml index 00453ad82d..3ff2a56d31 100644 --- a/phpunit-integration-legacy.xml +++ b/phpunit-integration-legacy.xml @@ -28,6 +28,19 @@ 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 index 3fe71d14b5..352961bb2b 100644 --- a/phpunit-integration.xml +++ b/phpunit-integration.xml @@ -22,6 +22,22 @@ 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/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 index 9a9be9bfca..0a8866eb4d 100644 --- a/tests/integration/Core/TestKernel.php +++ b/tests/integration/Core/TestKernel.php @@ -8,16 +8,51 @@ namespace Ibexa\Tests\Integration\Core; +use DAMA\DoctrineTestBundle\DAMADoctrineTestBundle; +use Ibexa\Contracts\Core\Persistence\Handler; +use Ibexa\Contracts\Core\Repository\BookmarkService; +use Ibexa\Contracts\Core\Repository\TrashService; use Ibexa\Contracts\Core\Test\Persistence\Fixture\YamlFixture; use Ibexa\Contracts\Test\Core\IbexaTestKernel as BaseIbexaTestKernel; +use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; /** * Loads the same fixture set {@see \Ibexa\Contracts\Core\Test\IbexaTestKernel} (the package-internal * kernel predating ibexa/test-core) already used, instead of the shared kernel's own generic default, * so tests already calibrated against it keep passing unchanged. + * + * Registers DAMADoctrineTestBundle so mutating tests can run without reimporting schema/fixtures + * before each one: DAMA wraps each test in a transaction that's rolled back afterwards, layered on + * top of the one-time schema/fixture import tests/integration/bootstrap.php already does. */ final class TestKernel extends BaseIbexaTestKernel { + public function registerContainerConfiguration(LoaderInterface $loader): void + { + $loader->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'); From 34bca014b3455e56474969c74d1cde12a252de80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Sat, 22 Aug 2026 00:43:13 +0200 Subject: [PATCH 6/6] Migrated 13 mutating RepositoryTestCase-based tests to the Bootstrapper Converts self::getXxxService()/self::setAdministratorUser() calls to $this->getIbexaTestCore()->getXxxService() now that RepositoryTestCase no longer boots through the legacy per-test schema/fixture loading. TrashService and URLAliasService have no dedicated getter on IbexaTestCoreInterface, so DeleteContentTest and UrlAliasLookupTest fall back to getServiceByClassName() for those two. --- .../Legacy/BookmarkHandlerTest.php | 2 +- ...ntUpdateAfterAddingFieldDefinitionTest.php | 22 +++++++++---------- ...slatableFieldsFromPublishedVersionTest.php | 18 +++++++-------- ...pyTranslationsFromPublishedVersionTest.php | 10 ++++----- .../ContentService/DeleteContentTest.php | 9 ++++---- .../ContentService/ImageAssetTest.php | 4 ++-- .../ContentService/LoadVersionInfoTest.php | 6 ++--- .../MaxLanguagesContentServiceTest.php | 2 +- .../ContentService/UpdateContentTest.php | 20 ++++++++--------- .../Repository/SearchServiceBookmarkTest.php | 5 +++-- .../SearchServiceContentNameTest.php | 8 +++---- .../Repository/SearchServiceImageTest.php | 14 ++++++------ .../URLAliasService/UrlAliasLookupTest.php | 3 ++- 13 files changed, 63 insertions(+), 60 deletions(-) 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/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/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');