Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions skeleton/ibexa-ee/tests/integration/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down
57 changes: 2 additions & 55 deletions skeleton/ibexa-ee/tests/integration/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
13 changes: 4 additions & 9 deletions skeleton/ibexa-oss/tests/integration/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down
57 changes: 2 additions & 55 deletions skeleton/ibexa-oss/tests/integration/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();