Skip to content
Open
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
11 changes: 11 additions & 0 deletions dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"recipesEndpoint": "",
"packages": [
{
"requirement": "dev-feature/schema-applier-4.6 as 4.6.x-dev",
"repositoryUrl": "https://github.com/ibexa/doctrine-schema.git",
"package": "ibexa/doctrine-schema",
"shouldBeAddedAsVCS": false
}
]
}
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8910,12 +8910,6 @@ parameters:
count: 1
path: src/contracts/Test/IbexaKernelTestCase.php

-
message: '#^Cannot call method importSchema\(\) on object\|null\.$#'
identifier: method.nonObject
count: 1
path: src/contracts/Test/IbexaKernelTestCase.php

-
message: '#^Method Ibexa\\Contracts\\Core\\Test\\Persistence\\Fixture\:\:load\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand Down
20 changes: 15 additions & 5 deletions src/contracts/Test/IbexaKernelTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
use Ibexa\Contracts\Core\Repository\URLAliasService;
use Ibexa\Contracts\Core\Repository\UserService;
use Ibexa\Contracts\Core\Test\Persistence\Fixture\FixtureImporter;
use Ibexa\Contracts\DoctrineSchema\Builder\SchemaBuilderInterface;
use Ibexa\Core\Repository\Values\User\UserReference;
use Ibexa\Tests\Core\Repository\LegacySchemaImporter;
use Ibexa\DoctrineSchema\Builder\SchemaApplier;
use RuntimeException;

/**
Expand All @@ -34,14 +35,23 @@ trait IbexaKernelTestTrait
{
final protected static function loadSchema(): void
{
$schemaImporter = self::getContainer()->get(LegacySchemaImporter::class);
foreach (static::getSchemaFiles() as $schemaFile) {
$schemaImporter->importSchema($schemaFile);
}
$schemaBuilder = self::getContainer()->get(SchemaBuilderInterface::class);
Comment on lines -37 to +38

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have already some helper method to get service correctly typed/recognized by phpstan (based on passed class-string value)? If so, we coud use it and remove asert here.

assert($schemaBuilder instanceof SchemaBuilderInterface);
$schema = $schemaBuilder->buildSchema();

// Constructed rather than fetched: SchemaApplier is a stateless helper, and its service is
// private and unreferenced in a plain test kernel, so the compiler removes it.
// drop first: this runs per test case, so the tables are normally already present
(new SchemaApplier(self::getDoctrineConnection()))->applySchema($schema, true);
}

/**
* @return iterable<string>
*
* @deprecated since Ibexa 4.6.x, no longer used. {@see loadSchema()} now builds the schema from
* {@see \Ibexa\Contracts\DoctrineSchema\Event\SchemaBuilderEvent} instead of reading
* raw schema files, so a bundle contributes its tables through its own
* BuildSchemaSubscriber and nothing needs to list files. Will be removed in 6.0.
*/
protected static function getSchemaFiles(): iterable
{
Expand Down
4 changes: 4 additions & 0 deletions src/contracts/Test/IbexaTestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
use Doctrine\DBAL\Connection;
use FOS\JsRoutingBundle\FOSJsRoutingBundle;
use Ibexa\Bundle\Core\IbexaCoreBundle;
use Ibexa\Bundle\DoctrineSchema\DoctrineSchemaBundle;
use Ibexa\Bundle\LegacySearchEngine\IbexaLegacySearchEngineBundle;
use Ibexa\Bundle\RepositoryInstaller\IbexaRepositoryInstallerBundle;
use Ibexa\Contracts\Core\Persistence\Handler;
use Ibexa\Contracts\Core\Persistence\TransactionHandler;
use Ibexa\Contracts\Core\Repository;
Expand Down Expand Up @@ -139,6 +141,8 @@ public function registerBundles(): iterable
{
yield new SecurityBundle();
yield new IbexaCoreBundle();
yield new DoctrineSchemaBundle();
yield new IbexaRepositoryInstallerBundle();
yield new IbexaLegacySearchEngineBundle();
yield new JMSTranslationBundle();
yield new FOSJsRoutingBundle();
Expand Down
6 changes: 6 additions & 0 deletions src/contracts/Test/IbexaTestKernelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public static function getAliasServiceId(string $id): string;

/**
* @return iterable<string>
*
* @deprecated since Ibexa 4.6.x. Test schema is built from
* {@see \Ibexa\Contracts\DoctrineSchema\Event\SchemaBuilderEvent} β€” the same path
* `ibexa:install` uses β€” so a kernel no longer declares which schema files to load;
* whichever bundles it registers is what the schema contains. Implementations may
* return an empty iterable. Will be removed in 6.0.
*/
public function getSchemaFiles(): iterable;

Expand Down
10 changes: 0 additions & 10 deletions tests/integration/RepositoryInstaller/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,11 @@

namespace Ibexa\Tests\Integration\RepositoryInstaller;

use Ibexa\Bundle\DoctrineSchema\DoctrineSchemaBundle;
use Ibexa\Bundle\RepositoryInstaller\IbexaRepositoryInstallerBundle;
use Ibexa\Bundle\RepositoryInstaller\Installer\CoreInstaller;
use Ibexa\Contracts\Core\Test\IbexaTestKernel;

final class TestKernel extends IbexaTestKernel
{
public function registerBundles(): iterable
{
yield from parent::registerBundles();

yield new DoctrineSchemaBundle();
yield new IbexaRepositoryInstallerBundle();
}

protected static function getExposedServicesByClass(): iterable
{
yield from parent::getExposedServicesByClass();
Expand Down