From 589eed163005e192babe7537439a14a94b8f7f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Thu, 10 Sep 2026 10:53:08 +0200 Subject: [PATCH] Generated bundles now bootstrap integration tests through Bootstrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The skeleton still shipped the pre-IBX-12358 hand-rolled bootstrap: boot the kernel, drop and create the database, run doctrine:schema:update, loop getSchemaFiles() through LegacySchemaImporter, loop getFixtures(), purge the search index. Every newly generated bundle was therefore born on a flow the rest of the org has already moved off, and ibexa/test-core 5.0 has shipped Bootstrapper for a while. tests/integration/bootstrap.php is now the same five-line Bootstrapper call every other package uses, and TestKernel registers IbexaTestCoreBundle, which Bootstrapper requires. The getSchemaFiles() override is dropped. It yielded parent::getSchemaFiles() and then yielded @IbexaCoreBundle's legacy schema.yaml again — which the parent already provides — so it was duplicating a file even before ibexa/test-core#43 deprecated the whole schema-file API. --- .../ibexa-ee/tests/integration/TestKernel.php | 13 ++--- .../ibexa-ee/tests/integration/bootstrap.php | 57 +------------------ .../tests/integration/TestKernel.php | 13 ++--- .../ibexa-oss/tests/integration/bootstrap.php | 57 +------------------ 4 files changed, 12 insertions(+), 128 deletions(-) diff --git a/skeleton/ibexa-ee/tests/integration/TestKernel.php b/skeleton/ibexa-ee/tests/integration/TestKernel.php index 4d7711f..acf29d5 100644 --- a/skeleton/ibexa-ee/tests/integration/TestKernel.php +++ b/skeleton/ibexa-ee/tests/integration/TestKernel.php @@ -8,19 +8,11 @@ namespace Ibexa\Tests\Integration\__BUNDLE_NAME__; +use Ibexa\Bundle\Test\Core\IbexaTestCoreBundle; use Ibexa\Contracts\Test\Core\IbexaTestKernel; final class TestKernel extends IbexaTestKernel { - public function getSchemaFiles(): iterable - { - yield from parent::getSchemaFiles(); - - yield from [ - $this->locateResource('@IbexaCoreBundle/Resources/config/storage/legacy/schema.yaml'), - ]; - } - public function getFixtures(): iterable { yield from parent::getFixtures(); @@ -29,6 +21,9 @@ public function getFixtures(): iterable public function registerBundles(): iterable { yield from parent::registerBundles(); + + // required by Bootstrapper: it provides HooksExecutorInterface and the built-in hooks + yield new IbexaTestCoreBundle(); } protected static function getExposedServicesByClass(): iterable diff --git a/skeleton/ibexa-ee/tests/integration/bootstrap.php b/skeleton/ibexa-ee/tests/integration/bootstrap.php index 1ebba3b..8237b96 100644 --- a/skeleton/ibexa-ee/tests/integration/bootstrap.php +++ b/skeleton/ibexa-ee/tests/integration/bootstrap.php @@ -6,63 +6,10 @@ */ declare(strict_types=1); -use Ibexa\Contracts\Core\Search\VersatileHandler; -use Ibexa\Contracts\Core\Test\Persistence\Fixture\FixtureImporter; -use Ibexa\Tests\Core\Repository\LegacySchemaImporter; -use Ibexa\Tests\Integration\__BUNDLE_NAME__\TestKernel; -use Psr\Container\ContainerInterface; -use Symfony\Bundle\FrameworkBundle\Console\Application; -use Symfony\Component\Console\Input\ArrayInput; +use Ibexa\Contracts\Test\Core\Bootstrapper\Bootstrapper; require_once dirname(__DIR__, 2) . '/vendor/autoload.php'; chdir(dirname(__DIR__, 2)); -$kernel = new TestKernel('test', true); -$kernel->boot(); - -$application = new Application($kernel); -$application->setAutoExit(false); - -$databaseUrl = getenv('DATABASE_URL'); -if ($databaseUrl !== false && !str_starts_with($databaseUrl, 'sqlite')) { - $application->run(new ArrayInput([ - 'command' => 'doctrine:database:drop', - '--if-exists' => '1', - '--force' => '1', - '--quiet' => true, - ])); -} - -$application->run(new ArrayInput([ - 'command' => 'doctrine:database:create', - '--quiet' => true, -])); - -$application->run(new ArrayInput([ - 'command' => 'doctrine:schema:update', - '--em' => 'ibexa_default', - '--force' => true, - '--quiet' => true, -])); - -/** @var ContainerInterface $testContainer */ -$testContainer = $kernel->getContainer()->get('test.service_container'); - -$schemaImporter = $testContainer->get(LegacySchemaImporter::class); -foreach ($kernel->getSchemaFiles() as $file) { - $schemaImporter->importSchema($file); -} - -$fixtureImporter = $testContainer->get(FixtureImporter::class); -foreach ($kernel->getFixtures() as $fixture) { - $fixtureImporter->import($fixture); -} - -/** @var VersatileHandler $handler */ -$handler = $testContainer->get('ibexa.spi.search'); -$handler->purgeIndex(); - -// Add fixtures if applicable - -$kernel->shutdown(); +(new Bootstrapper())->bootstrap(); diff --git a/skeleton/ibexa-oss/tests/integration/TestKernel.php b/skeleton/ibexa-oss/tests/integration/TestKernel.php index 4d7711f..acf29d5 100644 --- a/skeleton/ibexa-oss/tests/integration/TestKernel.php +++ b/skeleton/ibexa-oss/tests/integration/TestKernel.php @@ -8,19 +8,11 @@ namespace Ibexa\Tests\Integration\__BUNDLE_NAME__; +use Ibexa\Bundle\Test\Core\IbexaTestCoreBundle; use Ibexa\Contracts\Test\Core\IbexaTestKernel; final class TestKernel extends IbexaTestKernel { - public function getSchemaFiles(): iterable - { - yield from parent::getSchemaFiles(); - - yield from [ - $this->locateResource('@IbexaCoreBundle/Resources/config/storage/legacy/schema.yaml'), - ]; - } - public function getFixtures(): iterable { yield from parent::getFixtures(); @@ -29,6 +21,9 @@ public function getFixtures(): iterable public function registerBundles(): iterable { yield from parent::registerBundles(); + + // required by Bootstrapper: it provides HooksExecutorInterface and the built-in hooks + yield new IbexaTestCoreBundle(); } protected static function getExposedServicesByClass(): iterable diff --git a/skeleton/ibexa-oss/tests/integration/bootstrap.php b/skeleton/ibexa-oss/tests/integration/bootstrap.php index 1ebba3b..8237b96 100644 --- a/skeleton/ibexa-oss/tests/integration/bootstrap.php +++ b/skeleton/ibexa-oss/tests/integration/bootstrap.php @@ -6,63 +6,10 @@ */ declare(strict_types=1); -use Ibexa\Contracts\Core\Search\VersatileHandler; -use Ibexa\Contracts\Core\Test\Persistence\Fixture\FixtureImporter; -use Ibexa\Tests\Core\Repository\LegacySchemaImporter; -use Ibexa\Tests\Integration\__BUNDLE_NAME__\TestKernel; -use Psr\Container\ContainerInterface; -use Symfony\Bundle\FrameworkBundle\Console\Application; -use Symfony\Component\Console\Input\ArrayInput; +use Ibexa\Contracts\Test\Core\Bootstrapper\Bootstrapper; require_once dirname(__DIR__, 2) . '/vendor/autoload.php'; chdir(dirname(__DIR__, 2)); -$kernel = new TestKernel('test', true); -$kernel->boot(); - -$application = new Application($kernel); -$application->setAutoExit(false); - -$databaseUrl = getenv('DATABASE_URL'); -if ($databaseUrl !== false && !str_starts_with($databaseUrl, 'sqlite')) { - $application->run(new ArrayInput([ - 'command' => 'doctrine:database:drop', - '--if-exists' => '1', - '--force' => '1', - '--quiet' => true, - ])); -} - -$application->run(new ArrayInput([ - 'command' => 'doctrine:database:create', - '--quiet' => true, -])); - -$application->run(new ArrayInput([ - 'command' => 'doctrine:schema:update', - '--em' => 'ibexa_default', - '--force' => true, - '--quiet' => true, -])); - -/** @var ContainerInterface $testContainer */ -$testContainer = $kernel->getContainer()->get('test.service_container'); - -$schemaImporter = $testContainer->get(LegacySchemaImporter::class); -foreach ($kernel->getSchemaFiles() as $file) { - $schemaImporter->importSchema($file); -} - -$fixtureImporter = $testContainer->get(FixtureImporter::class); -foreach ($kernel->getFixtures() as $fixture) { - $fixtureImporter->import($fixture); -} - -/** @var VersatileHandler $handler */ -$handler = $testContainer->get('ibexa.spi.search'); -$handler->purgeIndex(); - -// Add fixtures if applicable - -$kernel->shutdown(); +(new Bootstrapper())->bootstrap();