From 9c4d28e3e10981354be6a55468dc62b6958a03d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Fri, 30 Oct 2026 15:31:48 +0100 Subject: [PATCH 1/2] IBX-11939: Added the schema alignment test (#158) * IBX-11939: Added the schema alignment test The integration suite now also runs on the Doctrine Migrations install path, in one extra CI job per database on the newest PHP, and SchemaAlignmentTest checks there that the migrations create the schema SchemaBuilderEvent declares. The bootstrap switches between the two paths with IBEXA_TEST_SCHEMA_BUILDER_EVENT_ENABLED, and the test kernel registers the two Doctrine Migrations bundles that path needs. The extra run skips PHPStan, which the other runs already do. * IBX-11939: Ran every CI step on the Doctrine Migrations leg too The schema_builder_event=false leg skipped PHPStan. It now runs the same steps as the other legs, and IBEXA_TEST_SCHEMA_BUILDER_EVENT_ENABLED (1 or 0) picks the install path. * IBX-11939: Used SchemaInstallPath to select the schema install path in the bootstrap ibexa/test-core#73 returns the DatabaseSchemaHook and DoctrineMigrationsSchemaHook options for either path, so the bootstrap only reads IBEXA_TEST_SCHEMA_BUILDER_EVENT_ENABLED itself. * IBX-11939: Passed SchemaInstallPath whether the Doctrine Migrations path is enabled * IBX-11939: Wrote the empty SchemaAlignmentTest body on one line The single_line_empty_body rule of PHP CS Fixer 3.95 wants it, now that 4.6 requires ibexa/code-style ~2.3.1. --- .github/workflows/backend-ci.yaml | 10 +++++++++- composer.json | 1 + tests/bootstrap.php | 13 ++++++++++++- tests/integration/IbexaTestKernel.php | 6 ++++++ tests/integration/SchemaAlignmentTest.php | 16 ++++++++++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 tests/integration/SchemaAlignmentTest.php diff --git a/.github/workflows/backend-ci.yaml b/.github/workflows/backend-ci.yaml index ba3456c2..af1bf273 100644 --- a/.github/workflows/backend-ci.yaml +++ b/.github/workflows/backend-ci.yaml @@ -33,7 +33,7 @@ jobs: composer run-script check-cs -- --format=checkstyle | cs2pr tests: - name: Unit tests & SQLite integration tests + name: Unit tests & SQLite integration tests (${{ matrix.php }}${{ !matrix.schema_builder_event && ', Doctrine Migrations' || '' }}) runs-on: "ubuntu-26.04" timeout-minutes: 15 @@ -44,6 +44,12 @@ jobs: - '7.4' - '8.3' - '8.4' + schema_builder_event: + - true + # One more run, on the Doctrine Migrations install path. + include: + - php: '8.4' + schema_builder_event: false steps: - uses: actions/checkout@v7 @@ -64,3 +70,5 @@ jobs: - name: Run test suite run: composer run-script --timeout=600 test + env: + IBEXA_TEST_SCHEMA_BUILDER_EVENT_ENABLED: ${{ matrix.schema_builder_event && '1' || '0' }} diff --git a/composer.json b/composer.json index c994cecc..948e9d0f 100644 --- a/composer.json +++ b/composer.json @@ -48,6 +48,7 @@ "symfony/security-http": "^5.0" }, "require-dev": { + "doctrine/doctrine-migrations-bundle": "^3.2", "ibexa/ci-scripts": "^0.2@dev", "ibexa/doctrine-schema": "~4.6.x-dev", "ibexa/search": "~4.6.x-dev", diff --git a/tests/bootstrap.php b/tests/bootstrap.php index fdfee57d..a77c8ece 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -6,10 +6,21 @@ */ declare(strict_types=1); +use Ibexa\Contracts\Test\Core\Bootstrapper\BaseFixtureHook; use Ibexa\Contracts\Test\Core\Bootstrapper\Bootstrapper; +use Ibexa\Contracts\Test\Core\Bootstrapper\SchemaInstallPath; require dirname(__DIR__) . '/vendor/autoload.php'; chdir(__DIR__ . '/..'); -(new Bootstrapper())->bootstrap(); +// Selects which of the two coexisting schema install paths this run exercises: the +// SchemaBuilderEvent one by default, or the Doctrine Migrations one with +// IBEXA_TEST_SCHEMA_BUILDER_EVENT_ENABLED=0. +$doctrineMigrationsEnabled = getenv('IBEXA_TEST_SCHEMA_BUILDER_EVENT_ENABLED') === '0'; + +(new Bootstrapper())->bootstrap(null, SchemaInstallPath::getBootstrapperOptions($doctrineMigrationsEnabled) + [ + // On the Doctrine Migrations path, ibexa/core's ImportDataMigration has already inserted the + // baseline repository content. + BaseFixtureHook::class => [BaseFixtureHook::OPTION_LOAD_BASE_FIXTURE => !$doctrineMigrationsEnabled], +]); diff --git a/tests/integration/IbexaTestKernel.php b/tests/integration/IbexaTestKernel.php index 9f93d102..2425def9 100644 --- a/tests/integration/IbexaTestKernel.php +++ b/tests/integration/IbexaTestKernel.php @@ -8,6 +8,8 @@ namespace Ibexa\Tests\Integration\User; +use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle; +use Ibexa\Bundle\DoctrineMigrations\IbexaDoctrineMigrationsBundle; use Ibexa\Bundle\Notifications\IbexaNotificationsBundle; use Ibexa\Bundle\Test\Core\IbexaTestCoreBundle; use Ibexa\Bundle\User\IbexaUserBundle; @@ -28,6 +30,10 @@ public function registerBundles(): iterable yield new IbexaTestCoreBundle(); + yield new DoctrineMigrationsBundle(); + + yield new IbexaDoctrineMigrationsBundle(); + yield from [ new IbexaUserBundle(), new IbexaNotificationsBundle(), diff --git a/tests/integration/SchemaAlignmentTest.php b/tests/integration/SchemaAlignmentTest.php new file mode 100644 index 00000000..35bc0e5c --- /dev/null +++ b/tests/integration/SchemaAlignmentTest.php @@ -0,0 +1,16 @@ + Date: Fri, 30 Oct 2026 16:28:56 +0100 Subject: [PATCH 2/2] IBX-11939: Answered the password prompt in UpdateUserCommandTest The test passed `--password` as `true`, which skips the prompt and sets the password to "1". That only passed because test_data.yaml's user content type doesn't enforce the password rules; on the Doctrine Migrations path core's clean-install content type does. Passing the option without a value and answering the prompt tests the documented interactive form. --- tests/bundle/Command/UpdateUserCommandTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/bundle/Command/UpdateUserCommandTest.php b/tests/bundle/Command/UpdateUserCommandTest.php index 134c7c79..3ecd47d4 100644 --- a/tests/bundle/Command/UpdateUserCommandTest.php +++ b/tests/bundle/Command/UpdateUserCommandTest.php @@ -68,10 +68,12 @@ public function testExecuteWithEnableAndDisableOptionsReturnsFailure(): void public function testExecuteReturnsSuccess(): void { + // `--password` without a value, so the command asks for it + $this->commandTester->setInputs(['Ibexa-Password1']); $this->commandTester->execute( [ 'user' => 'anonymous', - '--password' => true, + '--password' => null, '--email' => 'foo@bar.com', '--enable' => true, ],