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();