From 18c55090a453d0c3ee03ba5f1725f6bab94242e2 Mon Sep 17 00:00:00 2001 From: Jasper Smet Date: Mon, 9 Nov 2026 09:47:31 +0100 Subject: [PATCH 1/6] Require PHP 8.5 and clean up PHPUnit diagnostics --- .github/workflows/ci.yml | 23 ++- README.md | 2 +- composer.json | 2 +- phpunit.xml.dist | 6 + .../Db/Adapter/AdapterFactoryTest.php | 9 +- .../Db/Adapter/RecordingAdapterTest.php | 13 +- tests/TestCase/Db/Table/TableTest.php | 26 +-- tests/TestCase/Migration/EnvironmentTest.php | 17 +- .../TestCase/Migration/ManagerFactoryTest.php | 2 +- tests/TestCase/Migration/ManagerTest.php | 155 ++++++------------ 10 files changed, 92 insertions(+), 163 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c2257473..1b1b98509 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,23 +23,20 @@ permissions: jobs: testsuite-linux: runs-on: ubuntu-22.04 + continue-on-error: ${{ matrix.php-version == '8.6' }} strategy: fail-fast: false matrix: - php-version: ['8.4', '8.5'] + php-version: ['8.5', '8.6'] db-type: [mariadb, mysql, pgsql, sqlite] prefer-lowest: [''] legacy-tables: [''] include: - - php-version: '8.4' + - php-version: '8.5' db-type: 'sqlite' prefer-lowest: 'prefer-lowest' - - php-version: '8.4' - db-type: 'mysql' - - php-version: '8.4' - db-type: 'pgsql' # Test unified cake_migrations table (non-legacy mode) - - php-version: '8.4' + - php-version: '8.5' db-type: 'mysql' legacy-tables: 'false' services: @@ -108,7 +105,7 @@ jobs: with: php-version: ${{ matrix.php-version }} extensions: mbstring, intl, pdo_${{ matrix.db-type }} - coverage: pcov + coverage: ${{ matrix.php-version == '8.5' && 'pcov' || 'none' }} - name: Get composer cache directory id: composer-cache @@ -128,6 +125,8 @@ jobs: run: | if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then composer update --prefer-lowest --prefer-stable + elif [[ ${{ matrix.php-version }} == '8.6' ]]; then + composer update --ignore-platform-req=php+ else composer update fi @@ -157,23 +156,23 @@ jobs: if [[ -n '${{ matrix.legacy-tables }}' ]]; then export LEGACY_TABLES='${{ matrix.legacy-tables }}' fi - if [[ ${{ matrix.php-version }} == '8.4' && ${{ matrix.db-type }} == 'mysql' ]]; then + if [[ ${{ matrix.php-version }} == '8.5' && ${{ matrix.db-type }} == 'mysql' ]]; then vendor/bin/phpunit --coverage-clover=coverage.xml else vendor/bin/phpunit fi - name: Code Coverage Report - if: success() && matrix.php-version == '8.4' && matrix.db-type == 'mysql' + if: success() && matrix.php-version == '8.5' && matrix.db-type == 'mysql' uses: codecov/codecov-action@v7 testsuite-windows: runs-on: windows-2022 - name: Windows - PHP 8.4 & SQL Server + name: Windows - PHP 8.5 & SQL Server env: EXTENSIONS: mbstring, intl, pdo_sqlsrv - PHP_VERSION: '8.4' + PHP_VERSION: '8.5' steps: - uses: actions/checkout@v7 diff --git a/README.md b/README.md index 83b2725e8..f24d86e5d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This is a Database Migrations system for CakePHP. The plugin provides a complete database migration solution with support for creating, running, and managing migrations. -This branch is for use with CakePHP **6.x**, requiring PHP 8.4 or higher. See [version map](https://github.com/cakephp/migrations/wiki#version-map) for details. +This branch is for use with CakePHP **6.x**, requiring PHP 8.5 or higher. See [version map](https://github.com/cakephp/migrations/wiki#version-map) for details. When upgrading from CakePHP 5, regenerate schema dump files with `bin/cake migrations dump` before baking a diff. Serialized schema metadata uses CakePHP 6's property names. diff --git a/composer.json b/composer.json index 67461455b..6a3d965e4 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "source": "https://github.com/cakephp/migrations" }, "require": { - "php": ">=8.4", + "php": ">=8.5", "cakephp/cache": "^6.0", "cakephp/database": "^6.0", "cakephp/orm": "^6.0" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2a1f57dca..e96fa0de0 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,6 +3,12 @@ colors="true" cacheDirectory=".phpunit.cache" bootstrap="tests/bootstrap.php" + failOnDeprecation="true" + failOnPhpunitDeprecation="true" + failOnPhpunitNotice="true" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnPhpunitDeprecations="true" + displayDetailsOnPhpunitNotices="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.1/phpunit.xsd" > diff --git a/tests/TestCase/Db/Adapter/AdapterFactoryTest.php b/tests/TestCase/Db/Adapter/AdapterFactoryTest.php index e1fd15594..dfdae5bcf 100644 --- a/tests/TestCase/Db/Adapter/AdapterFactoryTest.php +++ b/tests/TestCase/Db/Adapter/AdapterFactoryTest.php @@ -9,7 +9,6 @@ use Migrations\Db\Adapter\MysqlAdapter; use Migrations\Db\Adapter\TimedOutputAdapter; use Migrations\Test\TestCase\Db\Adapter\DefaultAdapterTrait; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use ReflectionMethod; use RuntimeException; @@ -94,14 +93,14 @@ public function testRegisterWrapperFailure(): void $this->factory->registerWrapper('test', $wrapper); } - private function getAdapterMock(): MockObject + private function getAdapterStub(): AdapterInterface { - return $this->getMockBuilder(AdapterInterface::class)->getMock(); + return $this->createStub(AdapterInterface::class); } public function testGetWrapper(): void { - $wrapper = $this->factory->getWrapper('timed', $this->getAdapterMock()); + $wrapper = $this->factory->getWrapper('timed', $this->getAdapterStub()); $this->assertInstanceOf(TimedOutputAdapter::class, $wrapper); } @@ -111,6 +110,6 @@ public function testGetWrapperFailure(): void $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Wrapper "nope" has not been registered'); - $this->factory->getWrapper('nope', $this->getAdapterMock()); + $this->factory->getWrapper('nope', $this->getAdapterStub()); } } diff --git a/tests/TestCase/Db/Adapter/RecordingAdapterTest.php b/tests/TestCase/Db/Adapter/RecordingAdapterTest.php index 248712ff2..df6b1affe 100644 --- a/tests/TestCase/Db/Adapter/RecordingAdapterTest.php +++ b/tests/TestCase/Db/Adapter/RecordingAdapterTest.php @@ -22,12 +22,9 @@ class RecordingAdapterTest extends TestCase protected function setUp(): void { - $stub = $this->getMockBuilder(AbstractAdapter::class) - ->setConstructorArgs([[]]) - ->getMock(); + $stub = $this->createStub(AbstractAdapter::class); - $stub->expects($this->any()) - ->method('isValidColumnType') + $stub->method('isValidColumnType') ->willReturn(true); $this->adapter = new RecordingAdapter($stub); @@ -65,13 +62,11 @@ public function testRecordingAdapterCanInvertAddColumn(): void { $this->adapter ->getAdapter() - ->expects($this->any()) ->method('hasTable') ->willReturn(true); $this->adapter ->getAdapter() - ->expects($this->any()) ->method('getColumnForType') ->willReturnCallback(function (string $columnName, string $type, array $options): Column { return (new Column()) @@ -94,7 +89,6 @@ public function testRecordingAdapterCanInvertRenameColumn(): void { $this->adapter ->getAdapter() - ->expects($this->any()) ->method('hasTable') ->willReturn(true); @@ -112,7 +106,6 @@ public function testRecordingAdapterCanInvertAddIndex(): void { $this->adapter ->getAdapter() - ->expects($this->any()) ->method('hasTable') ->willReturn(true); @@ -130,7 +123,6 @@ public function testRecordingAdapterCanInvertAddForeignKey(): void { $this->adapter ->getAdapter() - ->expects($this->any()) ->method('hasTable') ->willReturn(true); @@ -148,7 +140,6 @@ public function testGetInvertedCommandsThrowsExceptionForIrreversibleCommand(): { $this->adapter ->getAdapter() - ->expects($this->any()) ->method('hasTable') ->willReturn(true); diff --git a/tests/TestCase/Db/Table/TableTest.php b/tests/TestCase/Db/Table/TableTest.php index 204cc9d68..d968a157a 100644 --- a/tests/TestCase/Db/Table/TableTest.php +++ b/tests/TestCase/Db/Table/TableTest.php @@ -311,9 +311,7 @@ public function testAddTimestampsWithTimezone( public function testInsert(): void { - $adapterStub = $this->getMockBuilder(MysqlAdapter::class) - ->setConstructorArgs([[]]) - ->getMock(); + $adapterStub = $this->createStub(MysqlAdapter::class); $table = new Table('ntable', [], $adapterStub); $data = [ 'column1' => 'value1', @@ -328,9 +326,7 @@ public function testInsert(): void public function testInsertMultipleRowsWithoutZeroKey(): void { - $adapterStub = $this->getMockBuilder(MysqlAdapter::class) - ->setConstructorArgs([[]]) - ->getMock(); + $adapterStub = $this->createStub(MysqlAdapter::class); $table = new Table('ntable', [], $adapterStub); $data = [ 1 => [ @@ -407,8 +403,7 @@ public function testSaveAfterSaveData(): void ], ]; - $adapterStub->expects($this->any()) - ->method('isValidColumnType') + $adapterStub->method('isValidColumnType') ->willReturn(true); $adapterStub->expects($this->exactly(1)) ->method('bulkinsert') @@ -427,9 +422,7 @@ public function testSaveAfterSaveData(): void public function testResetAfterAddingData(): void { - $adapterStub = $this->getMockBuilder(MysqlAdapter::class) - ->setConstructorArgs([[]]) - ->getMock(); + $adapterStub = $this->createStub(MysqlAdapter::class); $table = new Table('ntable', [], $adapterStub); $columns = ['column1']; $table->insert($columns)->save(); @@ -438,9 +431,7 @@ public function testResetAfterAddingData(): void public function testPendingAfterAddingData(): void { - $adapterStub = $this->getMockBuilder(MysqlAdapter::class) - ->setConstructorArgs([[]]) - ->getMock(); + $adapterStub = $this->createStub(MysqlAdapter::class); $table = new Table('ntable', [], $adapterStub); $columns = ['column1']; $table->insert($columns); @@ -449,11 +440,8 @@ public function testPendingAfterAddingData(): void public function testPendingAfterAddingColumn(): void { - $adapterStub = $this->getMockBuilder(MysqlAdapter::class) - ->setConstructorArgs([[]]) - ->getMock(); - $adapterStub->expects($this->any()) - ->method('isValidColumnType') + $adapterStub = $this->createStub(MysqlAdapter::class); + $adapterStub->method('isValidColumnType') ->willReturn(true); $table = new Table('ntable', [], $adapterStub); $table->addColumn('column1', 'integer', ['null' => true]); diff --git a/tests/TestCase/Migration/EnvironmentTest.php b/tests/TestCase/Migration/EnvironmentTest.php index 6f2dce7d9..66f5871e3 100644 --- a/tests/TestCase/Migration/EnvironmentTest.php +++ b/tests/TestCase/Migration/EnvironmentTest.php @@ -98,12 +98,9 @@ public function testSchemaName(): void public function testCurrentVersion(): void { - $stub = $this->getMockBuilder(AbstractAdapter::class) - ->setConstructorArgs([[]]) - ->getMock(); - $stub->expects($this->any()) - ->method('getVersions') - ->willReturn([20110301080000]); + $stub = $this->createStub(AbstractAdapter::class); + $stub->method('getVersions') + ->willReturn([20110301080000]); $this->environment->setAdapter($stub); @@ -463,8 +460,8 @@ public function change(): void public function testGettingInputObject(): void { - $mock = $this->getMockBuilder(ConsoleIo::class)->getMock(); - $this->environment->setIo($mock); + $stub = $this->createStub(ConsoleIo::class); + $this->environment->setIo($stub); $inputObject = $this->environment->getIo(); $this->assertInstanceOf(ConsoleIo::class, $inputObject); } @@ -505,9 +502,7 @@ public function up(): void public function testExecuteSeedInit(): void { // stub adapter - $adapterStub = $this->getMockBuilder(AbstractAdapter::class) - ->setConstructorArgs([[]]) - ->getMock(); + $adapterStub = $this->createStub(AbstractAdapter::class); $this->environment->setAdapter($adapterStub); diff --git a/tests/TestCase/Migration/ManagerFactoryTest.php b/tests/TestCase/Migration/ManagerFactoryTest.php index af3b7d04b..1e311375a 100644 --- a/tests/TestCase/Migration/ManagerFactoryTest.php +++ b/tests/TestCase/Migration/ManagerFactoryTest.php @@ -37,7 +37,7 @@ public function testConnection(): void */ public function testConsoleIoInterface(): void { - $io = $this->createMock(ConsoleIoInterface::class); + $io = $this->createStub(ConsoleIoInterface::class); $factory = new ManagerFactory(['connection' => 'test']); $manager = $factory->createManager($io); diff --git a/tests/TestCase/Migration/ManagerTest.php b/tests/TestCase/Migration/ManagerTest.php index 2628afa38..38a1ca5a1 100644 --- a/tests/TestCase/Migration/ManagerTest.php +++ b/tests/TestCase/Migration/ManagerTest.php @@ -303,9 +303,7 @@ public function testPrintStatusMethodWithBreakpointSet(): void public function testPrintStatusMethodWithNoMigrations(): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); + $envStub = $this->createStub(Environment::class); // override the migrations directory to an empty one $configArray = $this->getConfigArray(); @@ -716,30 +714,23 @@ public function testMigrationsByDate(array $availableMigrations, string $dateStr public function testMigrationsByCount(array $availableMigrations, int $count, ?string $expectedMigration, string $message): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); + $envStub = $this->createStub(Environment::class); // getVersions returns already executed migrations, so it should be empty for new migrations - $envStub->expects($this->any()) - ->method('getVersions') + $envStub->method('getVersions') ->willReturn([]); // getCurrentVersion returns 0 when no migrations have been run - $envStub->expects($this->any()) - ->method('getCurrentVersion') + $envStub->method('getCurrentVersion') ->willReturn(0); // Mock getMigrations to return the available migrations $migrations = []; foreach ($availableMigrations as $version) { - $migration = $this->getMockBuilder(MigrationInterface::class) - ->getMock(); - $migration->expects($this->any()) - ->method('getVersion') + $migration = $this->createStub(MigrationInterface::class); + $migration->method('getVersion') ->willReturn((int)$version); - $migration->expects($this->any()) - ->method('getName') + $migration->method('getName') ->willReturn('TestMigration'); $migrations[$version] = $migration; } @@ -768,11 +759,8 @@ public function testMigrationsByCount(array $availableMigrations, int $count, ?s public function testRollbackToVersion(array $availableRollbacks, ?string $version, string|array|null $expectedOutput): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); - $envStub->expects($this->any()) - ->method('getVersionLog') + $envStub = $this->createStub(Environment::class); + $envStub->method('getVersionLog') ->willReturn($availableRollbacks); $this->manager->setEnvironment($envStub); @@ -801,11 +789,8 @@ public function testRollbackToVersion(array $availableRollbacks, ?string $versio public function testRollbackToDate(array $availableRollbacks, string $version, string|array|null $expectedOutput): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); - $envStub->expects($this->any()) - ->method('getVersionLog') + $envStub = $this->createStub(Environment::class); + $envStub->method('getVersionLog') ->willReturn($availableRollbacks); $this->manager->setEnvironment($envStub); @@ -833,26 +818,19 @@ public function testRollbackToDate(array $availableRollbacks, string $version, s public function testRollbackByCount(array $availableRollbacks, int $count, string|array|null $expectedOutput): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); - $envStub->expects($this->any()) - ->method('getVersionLog') + $envStub = $this->createStub(Environment::class); + $envStub->method('getVersionLog') ->willReturn($availableRollbacks); // Mock getMigrations to return migrations matching the version log $migrations = []; foreach ($availableRollbacks as $version => $details) { - $migration = $this->getMockBuilder(MigrationInterface::class) - ->getMock(); - $migration->expects($this->any()) - ->method('getVersion') + $migration = $this->createStub(MigrationInterface::class); + $migration->method('getVersion') ->willReturn((int)$version); - $migration->expects($this->any()) - ->method('getName') + $migration->method('getName') ->willReturn($details['migration_name'] ?: 'TestMigration'); - $migration->expects($this->any()) - ->method('shouldExecute') + $migration->method('shouldExecute') ->willReturn(true); $migrations[$version] = $migration; } @@ -888,11 +866,8 @@ public function testRollbackByCount(array $availableRollbacks, int $count, strin public function testRollbackToVersionByExecutionTime(array $availableRollbacks, ?string $version, string|array $expectedOutput): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); - $envStub->expects($this->any()) - ->method('getVersionLog') + $envStub = $this->createStub(Environment::class); + $envStub->method('getVersionLog') ->willReturn($availableRollbacks); // get a manager with a config whose version order is set to execution time @@ -927,11 +902,8 @@ public function testRollbackToVersionByExecutionTime(array $availableRollbacks, public function testRollbackToVersionByName(array $availableRollbacks, ?string $version, string|array $expectedOutput): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); - $envStub->expects($this->any()) - ->method('getVersionLog') + $envStub = $this->createStub(Environment::class); + $envStub->method('getVersionLog') ->willReturn($availableRollbacks); // get a manager with a config whose version order is set to execution time @@ -941,7 +913,8 @@ public function testRollbackToVersionByName(array $availableRollbacks, ?string $ $this->manager = new Manager($config, $this->io); $this->manager->setEnvironment($envStub); - $this->manager->rollback($availableRollbacks[$version]['migration_name'] ?? $version); + $target = $version === null ? null : ($availableRollbacks[$version]['migration_name'] ?? $version); + $this->manager->rollback($target); $output = $this->getOutput(); @@ -966,11 +939,8 @@ public function testRollbackToVersionByName(array $availableRollbacks, ?string $ public function testRollbackToDateByExecutionTime(array $availableRollbacks, ?string $date, string|array|null $expectedOutput): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); - $envStub->expects($this->any()) - ->method('getVersionLog') + $envStub = $this->createStub(Environment::class); + $envStub->method('getVersionLog') ->willReturn($availableRollbacks); // get a manager with a config whose version order is set to execution time @@ -1001,17 +971,13 @@ public function testRollbackToDateByExecutionTime(array $availableRollbacks, ?st public function testRollbackToVersionWithSingleMigrationDoesNotFail(): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); - $envStub->expects($this->any()) - ->method('getVersionLog') - ->willReturn([ - '20120111235330' => ['version' => '20120111235330', 'migration' => '', 'breakpoint' => 0], - ]); - $envStub->expects($this->any()) - ->method('getVersions') - ->willReturn([20120111235330]); + $envStub = $this->createStub(Environment::class); + $envStub->method('getVersionLog') + ->willReturn([ + '20120111235330' => ['version' => '20120111235330', 'migration' => '', 'breakpoint' => 0], + ]); + $envStub->method('getVersions') + ->willReturn([20120111235330]); $this->manager->setEnvironment($envStub); $this->manager->rollback(); @@ -1027,25 +993,21 @@ public function testRollbackToVersionWithSingleMigrationDoesNotFail(): void public function testRollbackToVersionWithTwoMigrations(): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); - $envStub->expects($this->any()) - ->method('getVersionLog') - ->willReturn( - [ - '20120111235330' => ['version' => '20120111235330', 'migration' => '', 'breakpoint' => 0], - '20120116183504' => ['version' => '20120815145812', 'migration' => '', 'breakpoint' => 0], - ], - ); - $envStub->expects($this->any()) - ->method('getVersions') - ->willReturn( - [ - 20120111235330, - 20120116183504, - ], - ); + $envStub = $this->createStub(Environment::class); + $envStub->method('getVersionLog') + ->willReturn( + [ + '20120111235330' => ['version' => '20120111235330', 'migration' => '', 'breakpoint' => 0], + '20120116183504' => ['version' => '20120815145812', 'migration' => '', 'breakpoint' => 0], + ], + ); + $envStub->method('getVersions') + ->willReturn( + [ + 20120111235330, + 20120116183504, + ], + ); $this->manager->setEnvironment($envStub); $this->manager->rollback(); @@ -1062,11 +1024,8 @@ public function testRollbackToVersionWithTwoMigrations(): void public function testRollbackLast(array $availableRolbacks, string $versionOrder, string $expectedOutput): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); - $envStub->expects($this->any()) - ->method('getVersionLog') + $envStub = $this->createStub(Environment::class); + $envStub->method('getVersionLog') ->willReturn($availableRolbacks); // get a manager with a config whose version order is set to execution time @@ -2416,9 +2375,7 @@ public static function rollbackLastDataProvider(): array public function testExecuteSeedWorksAsExpected(): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); + $envStub = $this->createStub(Environment::class); $this->manager->setEnvironment($envStub); $this->manager->seed(); @@ -2431,9 +2388,7 @@ public function testExecuteSeedWorksAsExpected(): void public function testExecuteASingleSeedWorksAsExpected(): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); + $envStub = $this->createStub(Environment::class); $this->manager->setEnvironment($envStub); $this->manager->seed('UserSeeder'); @@ -2444,9 +2399,7 @@ public function testExecuteASingleSeedWorksAsExpected(): void public function testExecuteANonExistentSeedWorksAsExpected(): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); + $envStub = $this->createStub(Environment::class); $this->manager->setEnvironment($envStub); $this->expectException(InvalidArgumentException::class); @@ -2466,9 +2419,7 @@ public function testOrderSeeds(): void public function testSeedWillNotBeExecuted(): void { // stub environment - $envStub = $this->getMockBuilder(Environment::class) - ->setConstructorArgs(['mockenv', []]) - ->getMock(); + $envStub = $this->createStub(Environment::class); $this->manager->setEnvironment($envStub); $this->manager->seed('UserSeederNotExecuted'); From e92ba3a51c3371ee6f003f6de2b7da54769a129c Mon Sep 17 00:00:00 2001 From: Jasper Smet Date: Mon, 9 Nov 2026 10:36:51 +0100 Subject: [PATCH 2/6] Use CakePHP 6 predicates in migration queries --- src/Command/BakeMigrationDiffCommand.php | 3 ++- src/Db/Adapter/AbstractAdapter.php | 7 ++++--- src/Db/Adapter/MigrationsTableStorage.php | 6 ++++-- src/Db/Adapter/PostgresAdapter.php | 6 ++++-- src/Db/Adapter/SqliteAdapter.php | 6 ++++-- .../Adapter/UnifiedMigrationsTableStorage.php | 17 ++++++++++------- tests/TestCase/Db/Adapter/MysqlAdapterTest.php | 6 ++++-- .../TestCase/Db/Adapter/PostgresAdapterTest.php | 6 ++++-- tests/TestCase/Db/Adapter/SqliteAdapterTest.php | 6 ++++-- .../Db/Adapter/SqlserverAdapterTest.php | 6 ++++-- .../UnifiedMigrationsTableStorageTest.php | 3 ++- tests/TestCase/Migration/ManagerTest.php | 1 + tests/TestCase/TestCase.php | 5 +++-- tests/TestCase/TestSuite/MigratorTest.php | 3 ++- ...31121929_direction_aware_reversible_down.php | 3 ++- 15 files changed, 54 insertions(+), 30 deletions(-) diff --git a/src/Command/BakeMigrationDiffCommand.php b/src/Command/BakeMigrationDiffCommand.php index b57e9faa0..5cddf0d6b 100644 --- a/src/Command/BakeMigrationDiffCommand.php +++ b/src/Command/BakeMigrationDiffCommand.php @@ -37,6 +37,7 @@ use Migrations\Util\UtilTrait; use ReflectionException; use ReflectionProperty; +use function Cake\Database\Expression\equals; /** * Task class for generating migration diff files. @@ -172,7 +173,7 @@ protected function setup(): void // In unified table mode, filter by the current plugin context if ($this->phinxTable === UnifiedMigrationsTableStorage::TABLE_NAME) { - $query->where(['plugin IS' => $this->plugin]); + $query->where(['plugin' => equals($this->plugin)]); } $migratedItems = $query->execute()->fetchAll('assoc'); diff --git a/src/Db/Adapter/AbstractAdapter.php b/src/Db/Adapter/AbstractAdapter.php index 9ab562d42..3c37f74d3 100644 --- a/src/Db/Adapter/AbstractAdapter.php +++ b/src/Db/Adapter/AbstractAdapter.php @@ -62,6 +62,7 @@ use PDOException; use RuntimeException; use function Cake\Core\deprecationWarning; +use function Cake\Database\Expression\equals; /** * Base Abstract Database Adapter. @@ -1125,11 +1126,11 @@ public function removeSeedFromLog(SeedInterface $seed): AdapterInterface if ($plugin !== null) { // Also remove entries logged before plugin attribution was fixed. $conditions['OR'] = [ - 'plugin' => $plugin, - 'plugin IS' => null, + ['plugin' => $plugin], + ['plugin' => equals(null)], ]; } else { - $conditions['plugin IS'] = null; + $conditions['plugin'] = equals(null); } $query = $this->getDeleteBuilder(); diff --git a/src/Db/Adapter/MigrationsTableStorage.php b/src/Db/Adapter/MigrationsTableStorage.php index a859d2621..5502d1fa2 100644 --- a/src/Db/Adapter/MigrationsTableStorage.php +++ b/src/Db/Adapter/MigrationsTableStorage.php @@ -20,6 +20,8 @@ use InvalidArgumentException; use Migrations\Db\Table; use Migrations\MigrationInterface; +use function Cake\Database\Expression\in; +use function Cake\Database\Expression\notEquals; /** * Backwards compatibility layer for migration table storage. @@ -72,7 +74,7 @@ public function cleanupMissing(array $missingVersions): void { $this->adapter->beginTransaction(); try { - $where = ['version IN' => $missingVersions]; + $where = ['version' => in($missingVersions)]; $delete = $this->adapter->getDeleteBuilder() ->from($this->schemaTableName) ->where($where); @@ -159,7 +161,7 @@ public function resetAllBreakpoints(): int 'start_time' => $query->identifier('start_time'), ]) ->where([ - 'breakpoint !=' => 0, + 'breakpoint' => notEquals(0), ]); return $this->adapter->executeQuery($query); diff --git a/src/Db/Adapter/PostgresAdapter.php b/src/Db/Adapter/PostgresAdapter.php index 84c3f1803..4b92da697 100644 --- a/src/Db/Adapter/PostgresAdapter.php +++ b/src/Db/Adapter/PostgresAdapter.php @@ -26,6 +26,8 @@ use Migrations\Db\Table\Trigger; use Migrations\Db\Table\View; use RuntimeException; +use function Cake\Database\Expression\comparison; +use function Cake\Database\Expression\notEquals; class PostgresAdapter extends AbstractAdapter { @@ -1153,8 +1155,8 @@ public function getAllSchemas(): array $query->select(['schema_name']) ->from('information_schema.schemata') ->where([ - ['schema_name !=' => 'information_schema'], - ['schema_name !~' => '^pg_'], + ['schema_name' => notEquals('information_schema')], + ['schema_name' => comparison('!~', '^pg_')], ]); $items = $query->execute()->fetchAll('assoc'); $schemaNames = []; diff --git a/src/Db/Adapter/SqliteAdapter.php b/src/Db/Adapter/SqliteAdapter.php index 9736f38f4..e37101405 100644 --- a/src/Db/Adapter/SqliteAdapter.php +++ b/src/Db/Adapter/SqliteAdapter.php @@ -25,6 +25,8 @@ use Migrations\Db\Table\View; use PDOException; use RuntimeException; +use function Cake\Database\Expression\in; +use function Cake\Database\Expression\isNotNull; use const FILTER_VALIDATE_BOOLEAN; /** @@ -693,9 +695,9 @@ protected function bufferIndicesAndTriggers(AlterInstructions $instructions, str ->select('*') ->from('sqlite_master') ->where([ - 'type IN' => ['index', 'trigger'], + 'type' => in(['index', 'trigger']), 'tbl_name' => $tableName, - 'sql IS NOT' => null, + 'sql' => isNotNull(), ]); $rows = $query->execute()->fetchAll('assoc'); diff --git a/src/Db/Adapter/UnifiedMigrationsTableStorage.php b/src/Db/Adapter/UnifiedMigrationsTableStorage.php index fab2cf686..35170d73c 100644 --- a/src/Db/Adapter/UnifiedMigrationsTableStorage.php +++ b/src/Db/Adapter/UnifiedMigrationsTableStorage.php @@ -20,6 +20,9 @@ use InvalidArgumentException; use Migrations\Db\Table; use Migrations\MigrationInterface; +use function Cake\Database\Expression\equals; +use function Cake\Database\Expression\in; +use function Cake\Database\Expression\notEquals; /** * Unified migration table storage. @@ -59,8 +62,8 @@ public function cleanupMissing(array $missingVersions): void { $this->adapter->beginTransaction(); try { - $where = ['version IN' => $missingVersions]; - $where['plugin IS'] = $this->adapter->getOption('plugin'); + $where = ['version' => in($missingVersions)]; + $where['plugin'] = equals($this->adapter->getOption('plugin')); $delete = $this->adapter->getDeleteBuilder() ->from(self::TABLE_NAME) @@ -84,7 +87,7 @@ public function getVersions(array $orderBy): SelectQuery $query = $this->adapter->getSelectBuilder(); $query->select('*') ->from(self::TABLE_NAME) - ->where(['plugin IS' => $this->plugin]) + ->where(['plugin' => equals($this->plugin)]) ->orderBy($orderBy); return $query; @@ -127,7 +130,7 @@ public function recordDown(MigrationInterface $migration): void ->from(self::TABLE_NAME) ->where([ 'version' => (string)$migration->getVersion(), - 'plugin IS' => $this->plugin, + 'plugin' => equals($this->plugin), ]); $this->adapter->executeQuery($query); @@ -176,8 +179,8 @@ public function resetAllBreakpoints(): int 'start_time' => $query->identifier('start_time'), ]) ->where([ - 'breakpoint !=' => 0, - 'plugin IS' => $this->plugin, + 'breakpoint' => notEquals(0), + 'plugin' => equals($this->plugin), ]); return $this->adapter->executeQuery($query); @@ -200,7 +203,7 @@ public function markBreakpoint(MigrationInterface $migration, bool $state): void ]) ->where([ 'version' => $migration->getVersion(), - 'plugin IS' => $this->plugin, + 'plugin' => equals($this->plugin), ]); $this->adapter->executeQuery($query); diff --git a/tests/TestCase/Db/Adapter/MysqlAdapterTest.php b/tests/TestCase/Db/Adapter/MysqlAdapterTest.php index 30a2c8044..f25fa3e07 100644 --- a/tests/TestCase/Db/Adapter/MysqlAdapterTest.php +++ b/tests/TestCase/Db/Adapter/MysqlAdapterTest.php @@ -26,6 +26,8 @@ use PHPUnit\Framework\Attributes\RunInSeparateProcess; use PHPUnit\Framework\TestCase; use RuntimeException; +use function Cake\Database\Expression\greaterThanOrEquals; +use function Cake\Database\Expression\lessThan; class MysqlAdapterTest extends TestCase { @@ -2476,7 +2478,7 @@ public function testQueryBuilder(): void $stm = $builder ->select('*') ->from('table1') - ->where(['int_col >=' => 2]) + ->where(['int_col' => greaterThanOrEquals(2)]) ->execute(); $this->assertEquals(1, $stm->rowCount()); @@ -2488,7 +2490,7 @@ public function testQueryBuilder(): void $builder = $this->adapter->getDeleteBuilder(); $stm = $builder ->delete('table1') - ->where(['int_col <' => 2]) + ->where(['int_col' => lessThan(2)]) ->execute(); $this->assertEquals(1, $stm->rowCount()); diff --git a/tests/TestCase/Db/Adapter/PostgresAdapterTest.php b/tests/TestCase/Db/Adapter/PostgresAdapterTest.php index 831386949..329580e89 100644 --- a/tests/TestCase/Db/Adapter/PostgresAdapterTest.php +++ b/tests/TestCase/Db/Adapter/PostgresAdapterTest.php @@ -25,6 +25,8 @@ use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use RuntimeException; +use function Cake\Database\Expression\greaterThanOrEquals; +use function Cake\Database\Expression\lessThan; class PostgresAdapterTest extends TestCase { @@ -2844,7 +2846,7 @@ public function testQueryBuilder(): void $stm = $builder ->select('*') ->from('table1') - ->where(['int_col >=' => 2]) + ->where(['int_col' => greaterThanOrEquals(2)]) ->execute(); $this->assertEquals(1, $stm->rowCount()); @@ -2856,7 +2858,7 @@ public function testQueryBuilder(): void $builder = $this->adapter->getDeleteBuilder(); $stm = $builder ->delete('table1') - ->where(['int_col <' => 2]) + ->where(['int_col' => lessThan(2)]) ->execute(); $this->assertEquals(1, $stm->rowCount()); diff --git a/tests/TestCase/Db/Adapter/SqliteAdapterTest.php b/tests/TestCase/Db/Adapter/SqliteAdapterTest.php index 7471012de..5242f1d07 100644 --- a/tests/TestCase/Db/Adapter/SqliteAdapterTest.php +++ b/tests/TestCase/Db/Adapter/SqliteAdapterTest.php @@ -23,6 +23,8 @@ use PHPUnit\Framework\Attributes\DataProvider; use ReflectionObject; use RuntimeException; +use function Cake\Database\Expression\greaterThanOrEquals; +use function Cake\Database\Expression\lessThan; class SqliteAdapterTest extends TestCase { @@ -2024,7 +2026,7 @@ public function testQueryBuilder(): void $stm = $builder ->select('*') ->from('table1') - ->where(['int_col >=' => 2]) + ->where(['int_col' => greaterThanOrEquals(2)]) ->execute(); $this->assertEquals(0, $stm->rowCount()); @@ -2036,7 +2038,7 @@ public function testQueryBuilder(): void $builder = $this->adapter->getDeleteBuilder(); $stm = $builder ->delete('table1') - ->where(['int_col <' => 2]) + ->where(['int_col' => lessThan(2)]) ->execute(); $this->assertEquals(1, $stm->rowCount()); diff --git a/tests/TestCase/Db/Adapter/SqlserverAdapterTest.php b/tests/TestCase/Db/Adapter/SqlserverAdapterTest.php index 91dc7d0ae..cdf63c4b9 100644 --- a/tests/TestCase/Db/Adapter/SqlserverAdapterTest.php +++ b/tests/TestCase/Db/Adapter/SqlserverAdapterTest.php @@ -19,6 +19,8 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; +use function Cake\Database\Expression\greaterThanOrEquals; +use function Cake\Database\Expression\lessThan; class SqlserverAdapterTest extends TestCase { @@ -1418,7 +1420,7 @@ public function testQueryBuilder(): void $stm = $builder ->select('*') ->from('table1') - ->where(['int_col >=' => 2]) + ->where(['int_col' => greaterThanOrEquals(2)]) ->execute(); $this->assertEquals(1, $stm->rowCount()); @@ -1432,7 +1434,7 @@ public function testQueryBuilder(): void $builder = $this->adapter->getDeleteBuilder(); $stm = $builder ->delete('table1') - ->where(['int_col <' => 2]) + ->where(['int_col' => lessThan(2)]) ->execute(); $stm->closeCursor(); diff --git a/tests/TestCase/Db/Adapter/UnifiedMigrationsTableStorageTest.php b/tests/TestCase/Db/Adapter/UnifiedMigrationsTableStorageTest.php index 223609ad5..9621c015a 100644 --- a/tests/TestCase/Db/Adapter/UnifiedMigrationsTableStorageTest.php +++ b/tests/TestCase/Db/Adapter/UnifiedMigrationsTableStorageTest.php @@ -8,6 +8,7 @@ use Exception; use Migrations\Db\Adapter\UnifiedMigrationsTableStorage; use Migrations\Test\TestCase\TestCase; +use function Cake\Database\Expression\equals; /** * Tests for UnifiedMigrationsTableStorage. @@ -187,7 +188,7 @@ public function testAppAndPluginMigrationsAreSeparated(): void $appCount = $connection->selectQuery() ->select(['count' => $connection->selectQuery()->func()->count('*')]) ->from(UnifiedMigrationsTableStorage::TABLE_NAME) - ->where(['plugin IS' => null]) + ->where(['plugin' => equals(null)]) ->execute() ->fetch('assoc'); diff --git a/tests/TestCase/Migration/ManagerTest.php b/tests/TestCase/Migration/ManagerTest.php index 38a1ca5a1..ecddc58a7 100644 --- a/tests/TestCase/Migration/ManagerTest.php +++ b/tests/TestCase/Migration/ManagerTest.php @@ -913,6 +913,7 @@ public function testRollbackToVersionByName(array $availableRollbacks, ?string $ $this->manager = new Manager($config, $this->io); $this->manager->setEnvironment($envStub); + $target = $version === null ? null : ($availableRollbacks[$version]['migration_name'] ?? $version); $this->manager->rollback($target); diff --git a/tests/TestCase/TestCase.php b/tests/TestCase/TestCase.php index 50a6e240a..6ab7c7c19 100644 --- a/tests/TestCase/TestCase.php +++ b/tests/TestCase/TestCase.php @@ -23,6 +23,7 @@ use Cake\TestSuite\StringCompareTrait; use Cake\TestSuite\TestCase as BaseTestCase; use Migrations\Db\Adapter\UnifiedMigrationsTableStorage; +use function Cake\Database\Expression\equals; abstract class TestCase extends BaseTestCase { @@ -180,7 +181,7 @@ protected function clearMigrationRecords(string $connectionName = 'test', ?strin if ($this->isUsingUnifiedTable()) { $query = $connection->deleteQuery() ->delete($tableName) - ->where(['plugin IS' => $plugin]); + ->where(['plugin' => equals($plugin)]); } else { $query = $connection->deleteQuery() ->delete($tableName); @@ -211,7 +212,7 @@ protected function getMigrationRecordCount(string $connectionName = 'test', ?str ->from($tableName); if ($this->isUsingUnifiedTable()) { - $query->where(['plugin IS' => $plugin]); + $query->where(['plugin' => equals($plugin)]); } $result = $query->execute()->fetch('assoc'); diff --git a/tests/TestCase/TestSuite/MigratorTest.php b/tests/TestCase/TestSuite/MigratorTest.php index 3a9804400..da67b46a1 100644 --- a/tests/TestCase/TestSuite/MigratorTest.php +++ b/tests/TestCase/TestSuite/MigratorTest.php @@ -24,6 +24,7 @@ use Migrations\TestSuite\Migrator; use PHPUnit\Framework\Attributes\Depends; use RuntimeException; +use function Cake\Database\Expression\equals; class MigratorTest extends TestCase { @@ -59,7 +60,7 @@ protected function getMigratorWhereClause(?string $plugin = 'Migrator'): array return []; } - return $plugin === null ? ['plugin IS' => null] : ['plugin' => $plugin]; + return $plugin === null ? ['plugin' => equals(null)] : ['plugin' => $plugin]; } protected function makeInspectableMigrator(): Migrator diff --git a/tests/test_app/config/Reversiblemigrations/20170831121929_direction_aware_reversible_down.php b/tests/test_app/config/Reversiblemigrations/20170831121929_direction_aware_reversible_down.php index 3229cd498..2f3fc8582 100644 --- a/tests/test_app/config/Reversiblemigrations/20170831121929_direction_aware_reversible_down.php +++ b/tests/test_app/config/Reversiblemigrations/20170831121929_direction_aware_reversible_down.php @@ -3,6 +3,7 @@ use Cake\Database\Query; use Migrations\Db\Table\Column; use Migrations\BaseMigration; +use function Cake\Database\Expression\like; class DirectionAwareReversibleDown extends BaseMigration { @@ -20,7 +21,7 @@ public function change(): void $query ->update('change_direction_test') ->set(['subthing' => $query->identifier('thing')]) - ->where(['thing LIKE' => '%-%']) + ->where(['thing' => like('%-%')]) ->execute(); } else { $this From 4b99fdee261402d490202d0ca0a268c31f457e98 Mon Sep 17 00:00:00 2001 From: Jasper Smet Date: Mon, 9 Nov 2026 10:43:15 +0100 Subject: [PATCH 3/6] Refresh schema fixtures for CakePHP 6 column serialization --- .../schema-dump-test_comparisons_mysql.lock | Bin 1938 -> 1734 bytes .../schema-dump-test_comparisons_pgsql.lock | Bin 1814 -> 1610 bytes .../schema-dump-test_comparisons_mysql.lock | Bin 1373 -> 1237 bytes .../schema-dump-test_comparisons_mysql.lock | Bin 9487 -> 8525 bytes .../schema-dump-test_comparisons_pgsql.lock | Bin 8696 -> 7760 bytes .../schema-dump-test_comparisons_mysql.lock | Bin 3933 -> 3473 bytes .../schema-dump-test_comparisons_pgsql.lock | Bin 3750 -> 3290 bytes .../schema-dump-test_comparisons_mysql.lock | Bin 934 -> 866 bytes .../schema-dump-test_comparisons_mysql.lock | Bin 934 -> 866 bytes .../schema-dump-test_comparisons_mysql.lock | Bin 934 -> 866 bytes 10 files changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/comparisons/Diff/addRemove/schema-dump-test_comparisons_mysql.lock b/tests/comparisons/Diff/addRemove/schema-dump-test_comparisons_mysql.lock index 92a7ea8a28c330db0df280d8bec37af1b2a66b46..67a212b427eb0dce9baa461de49b231a1ca4f6f5 100644 GIT binary patch literal 1734 zcmd^AyKdt!5X`r*yvlOoJg6>7lj1JLi)1A)ISc?@GSvL$1k^*!5Hh>t`&Uv}Rg=hv)EEo9HpT#=ZJ>%A-{8xg zF(O~d8IJf^(pq&Ui2N7M*HRd=RoIAJ%Pd0#?dg(i&|$|(9J-UDB1=vM0#8muq;*ti zuNyl=v@IOfNKKIi=ClsXf-?Zy*gtIvj1&NqqN&q$FEJTri(8%by0Tm-6_59f8S>DO zcRVjf%`m%)nwo;!y~O_eS}epE0F|}g9>_D|MmbNB=-x|wM!N>Y&e34ZK9T{G^}%Ud zeN=_{Vv!~>m4UVUA{lt1QxPzAwA_XD?Q41!=C#m$lb@{&>e99#*Fvguw3+4~se@M( zXbaSjY)JpMzP&D3ncm9SbAGD!Un`3bW@19q6*=0A|MiKYj0LnUY0E~dU=i;ehjP(F zEw)RcM*J3y8DOo`wQ?{n_;PmAOb@9d`7iQ-c(Bwd%FyS;vQbJ$EA4F?oD#sqe+L@- zv6H3^Fw4kx&MuBQz<9Ndo{htkwaw!_KS=C3>cR1%xt>@z1_lEV4^+2}i(My=hlz5S O|9%(_$MOGazyAy3At4n2 literal 1938 zcmeHIJ#X7E5Y2Dl*eP=ACZV=EONO>X)6GCYOJ|t~MF}JY*a-aJ`;OFCg=UC>03Ev7 zC*He{cXv<8Oul+~CxvoB7lypZf5@Aa6dUzI+XofYPI=n?EDltw?UULWO237?WzXzd zimOjoMPs_!!db~1HUmJH47Iv_18NgJgv{>wJzfFDs+vSTdJpDsYNHvCv<*~|<43(q zXN<^q@*0*tmy-6XGeP9vVY`pOhHMoMBG)p@_+b{Ux+EKPII({;BWq+)ktL@BA%8~5 zlC^bIXs;XlhgI9cQ4N@6MIQm6_JLE3&M8u3f3+nbd*jfvI(d2t1DDk2)mg7A%klfX zhWEyd7^!;ixXUrny3f6-DY(;9Y}qUWW^pp6JooxI7TJe5DCa2_bM_LDXpceG7xFj( z40H`tev!flr)_mPldJW5YT2C1I12w9m63}DkzgDx>cal+ISrk8F7(uqk7XAVM8|?$ z3%W1lcMh>+_%nuwj=&y1*mrH}Y;^x~`_9e9>h`CQ*X^5XmuERrGCQU7JzZ|*I3r$; zluiM(E$PUjp>V@q*^Wn14=nauAx8WbMF!K-I$bM=gA0wpW&EqgY?{GUBrQp&ZqSA~ z%2?-2eh^AWHRvS>IVFJM^vnUyQzcCsaNJ|ID^?`*0ivO8R37|!w6=Np%Hs@4K|Gw| fC6sT?+7pqP(m5wijl`rc;d(Y?J(4sIQ diff --git a/tests/comparisons/Diff/addRemove/schema-dump-test_comparisons_pgsql.lock b/tests/comparisons/Diff/addRemove/schema-dump-test_comparisons_pgsql.lock index c5f543d80b0d19a89d8b0ef282919286bc77bdee..e47d30f9fa01942ee9d91f0fc6c4c2590d064abd 100644 GIT binary patch literal 1610 zcmd^Au~O?W5ae4_QpJJ5<6J@u6hN0ou`iAWS@uZEOfpRVojp0RmB&y(`CezAZdZ4E z=e4GSJ_7wArF}G&<)F%Ex|)-^*YCW1&{3~+;N?rT;Z`qS^~&<_tmsyd#f;R&g{uA}F{zpF&<9O8l-+q+LB6E^_-OqOX>lBjo z(*?%Wyc4(7G@}oRV?N0U9ljKeJJMNlSCIAIwA#acV6Mftj(CEq!9;-rW;Rl7g&Pm1ZZ(U-Et}#g^W9_d=fbu@B)gVmPI*5k7j@AqZv-hcy8DRry=B|wJ7&; z1Pa}ulrEuOV)7(zs zdb9bQ!$|EHhZqZRh&kbN#kL2jH?o*REO~sui0~QM;}7#+iTh(rB=f*OW%ZR4uQ|%`k7b+7Rs$#`~R>Nz!Isz@=ASf8Ympl=#H z^}VUrv?w22+3?gSQ$OMTGnrm|m$s(1R8>IGsBOh3n|7L{&^?(>yaY}Hotg$@446c; zgP#%Wn;;IU1^GmVH%V1!251NWV{E}u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^jBDz7c|lzVOca9-K=-vk{QN4O6c?zZ{_~hBREl)7lU% c*FgY=g_SV=2EFb#=KB_l7i&1$Cgb_}UpyAQRR910 diff --git a/tests/comparisons/Diff/default/schema-dump-test_comparisons_pgsql.lock b/tests/comparisons/Diff/default/schema-dump-test_comparisons_pgsql.lock index 6b5c22de400353212021f2cc6ecdbf90588ecd35..d3149324aa7e869436010208eaf8e604bba32182 100644 GIT binary patch literal 7760 zcmeHLQE%Hg4Bl_?<2}{Qy4{qgp~C@(!?uUp-ULp9&Cn|gP+q0snhHVXD4P97<0#mZ8)0g+CIv0sd<*#`EbCuP4OW87r%38l` zWerM9-P4*Z@8HctRb|Udb%MY6Skjdqsyl*`G_J)X_Q6 z2jK+wWA1-+?FE2cHK0h&MBfP?(GTs_lR6({j-eyFn%j8B@`(?Q+5eF*0PUye13miJ zx4PZu1JbNVl{9WQlRN{+Ll@i5bsj7EBsl=59i&lzvT){@Qe+$xfK-Q^9&xK&-5B9K5e%>iIv8+n z4S}dXKOsU|ov0hf4jNmI1V->Hs-g7!1;Sr8Wc@!jM;8Tk-COE6jj$A`fY9Y`6{^e= z?-)zpd%J+i_q`iV%W<^O*&5-X5vk%~;mEMOwPvd=I3y@?evfa@n^81#+!}JwII`PV zOL#4ZJnR{?0~`uQ2geH7VAwI#=F>o{vGgoJ$q$CzN7?rm?J`6RVm7txj;06A15WO| zI|d>koIxCppn0%;q~k6M*=lSW2M(+7)*e9hkH!*swAd~KgFV|1>U;14P!JBja|e99 zawqa7a=Z)N;c;8gP0#rxxDLDCjN=R#<`68YBAzn1Co>*4ejWS_V*hKt5W_JYA!~Vb;|C2e z5BIUWOm#t}jCFkWU{G*9%wgPQXWHc^HgfflhsG$qWv4oUrVR+WoWps91DLjLW99j{ zxs9^|117d>Zw3W*oYeFh$9>~GO475pb5398MUyNGXGT?w)75bvHI2ZMc@%?lWF&qL z^PQ)G)1!>~vG_em!q|&sKZZp{9Xp~)P1N=Hw+;8=ZKLms>m|~IX#U~q<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9k3n7aUS+M0PK_F9yqQO Yj>@_+A?qj!ViRFU_Dj-Wjoxhj0<%|X)c^nh diff --git a/tests/comparisons/Diff/simple/schema-dump-test_comparisons_pgsql.lock b/tests/comparisons/Diff/simple/schema-dump-test_comparisons_pgsql.lock index de631af62948e0bb5bd56780bf76e0be98bedce2..28b98714951f6b285a6051a8f564cb9488a4a4c4 100644 GIT binary patch literal 3290 zcmeHKv2NQi5Y4x6>|{A{($J&3bVxfi-3$b@be4%ylt9v`4a5K5ca$tsO^nt?(ILqu zo%oJ-?~cbOB{RA6@}m^W1)Ur6V)|8HkENKYA2k1@f?6m~^KbczDm8yp3q$R*kavvC zMp9gTxXNp@t}MVx-m)1EbiuC1cPCuUB0|XQp4Z<t)%U_pAiARBbpGAM)TUW$?|ITZ+TG7Of+ zQLeqNZEw*wcT@q|S|;FW88`|?z-?{6HwApO21JtA)p0o%tgY9jJ?s$|7}EogiFZsC zyURdYNp(fRZ69Oe-6mXtqX982^(OVWQqEJ1aPK8PBTs{fE+PMj9`FxJeQ?^A=h8o( zOj@E+{<$QtmVcC(HaWQl1-YaGDSl7`^h%%&yqAZE=m!5_J`IP`^K+A27M-+8HaP~XZ9yB>eF~~=*UFG~hCanl z@fZX7q9FXtU;!lrVA4J;WrjXt?ukl-?9@@cB`F~$KIEO|13TUR14*akNbXvlQ@i3I z#UdBESr?rW1Ni5PT=&M|s5~d{A1JKqsJGw(pvCs7KQCwIn4(W+*K_iJbHi>KwvNKw zLb)k)U950a`-r@8x>62m7-By=QQKL4fC_od1qKct4>~>d(s%w#74H58TEgMrP~gu&vs%=maepsP%qrj z;CUX;o5{QpJmUw$zi=kBm3c*m&42LwDQ64uo0eaN6)RzA`7_^8EtW50RZ;lO_@nd8 zCY;@Uy33ntTPrvV{@~02kcESqKK=u0;XN47p4@qy0*Vqfv3d0F&34~q7L-;ig9YY70Pi#y)5D$+HV-tBfpFyt+SF zRna*-+h~_wf5WT`x~a+P{fp04a-CW9D;oicPEzh}`7RjTJD`5LC`Wyn#SsfH)5H~i2hVCT)7_#|bK zTyhFls)BY-j|-^jL(rjN9=!U${O1Io7lrya=ggq%;fM$lZSCajIZRAXBI2S9heGFhHqw}1Mc_zDQ zyw(l(ulBF88$bSf_a-SRz|ln9xvFFVl3n-FAJVxgl3Ox<>|7c-c3=UdDHn3 zArgD}tmCuYBbFeuDK^S@LGZ+sosc@I=3vm6sSPD0t~x~mx0wdjR^$P}^u0nO2-q0$Sk5iF~+CN9CVIbHL%DaNZ#d%l)zo$c&K`+G_QNuJ*?^%t|fEA$U& QmOgwf@$CzK?r%>we?Aas)&Kwi delta 384 zcmY+AJ#NA<6vtsHH(=}Hk%?47rOq9?6b@jLmte_$j%-IF6DuQKyL96My+qH!N&5WJ zL~Pd2{(t%YbX#06&##=#Rx=bDSn2o+XR;25gg?KR=lq~oij@bxrn_PtH8nJ%SDuyc z#NHxOfUQ3!QWO!%8qiBW1aT3>6hVP4AXwpn!h$^0&O#-fG&s>SJ(gHm(BzZwHadvL zgMElHxbJH6%rLdAj800&35036SdUJ&7z#YBs*F;j2W|hLd}qU_#Gaen-e~Z4*bUu( XT3UM$4knn2Hu5yiOr3sy=U?+bp8{yI diff --git a/tests/comparisons/Diff/withAutoIdIncompatibleSignedPrimaryKeys/schema-dump-test_comparisons_mysql.lock b/tests/comparisons/Diff/withAutoIdIncompatibleSignedPrimaryKeys/schema-dump-test_comparisons_mysql.lock index be1e3fbba40cff0f3b8384433da700ff4c371bd4..6f5b96599f340846f07b91a2b905abed554aa759 100644 GIT binary patch delta 334 zcmYLFJ8r`;3`ILMOHaWQBtiP4w;rHVdjQ3zRRJ<(NHkDSSvzLV0dj%fs3$2I8R;fI zzQ^~T&a29xvFFVl3n-FAJVxgl3Ox<>|7c-c3=UdDHn3 zArgD}tmCuYBbFeuDK^S@LGZ+sosc@I=3vm6sSPD0t~x~mx0wdjR^$P}^u0nO2-q0$Sk5iF~+CN9CVIbHL%DaNZ#d%l)zo$c&K`+G_QNuJ*?^%t|fEA$U& QmOgwf@$CzK?r%>we?Aas)&Kwi delta 384 zcmY+AJ#NA<6vtsHH(=}Hk%?47rOq9?6b@jLmte_$j%-IF6DuQKyL96My+qH!N&5WJ zL~Pd2{(t%YbX#06&##=#Rx=bDSn2o+XR;25gg?KR=lq~oij@bxrn_PtH8nJ%SDuyc z#NHxOfUQ3!QWO!%8qiBW1aT3>6hVP4AXwpn!h$^0&O#-fG&s>SJ(gHm(BzZwHadvL zgMElHxbJH6%rLdAj800&35036SdUJ&7z#YBs*F;j2W|hLd}qU_#Gaen-e~Z4*bUu( XT3UM$4knn2Hu5yiOr3sy=U?+bp8{yI diff --git a/tests/comparisons/Diff/withAutoIdIncompatibleUnsignedPrimaryKeys/schema-dump-test_comparisons_mysql.lock b/tests/comparisons/Diff/withAutoIdIncompatibleUnsignedPrimaryKeys/schema-dump-test_comparisons_mysql.lock index b6cc0d718dd81aecd27405fc785df2c45dd95ae1..da716ab7d3a9ad54316fddb430322660721582e5 100644 GIT binary patch delta 334 zcmYLFF;c@o3>+w+$t(1NBtt?XcX>c6c)-P$kDEEmo;!I4S7|A!c>o{aN4zAG&ja0Q zwX5B|@5kSV&yVX90=tf&%D6=cjXe~TX_&ER#aPHwS{6LU2-OAG%F|^-tsA32b=G;0 z5Q)9KmGNNrh$YBmij6Xk2%ead6H+JDTn!o$)ggzTi%yZib)rtS1=%6ERxE?r=-r-Q zhenSSKy%c6SLhkn2$oe@Bj@1RoQnI*i}6pVJx@7VXFI#m{+{}dBuy`K{l)C!GW`RZ Qr48>(eEWi*)&1Aq4L)yZ*8l(j delta 384 zcmY+AJC4FI5Qa$uH`s0)msAN70-QV0z#hOPldL6Y64{PKsc z+jyh^Yx^BYmU$#gKr8Lw#F-OQ1O?WBpoIkrbMi<#4TUta#TOmvSYn}}A)kQP-a%9r z^jlPmUtLL_5r&pU+XSWI1l+V(tVbhjbOmCu$GuWd58A$?e52i?_@2wyzHPwjVLx<_ Xw6OLd47^|{TFK*cX2`f)lfUE+pLS@o From 0bb3b468b170fb1bb2dea7f139d43f462bb14ab6 Mon Sep 17 00:00:00 2001 From: Jasper Smet Date: Mon, 9 Nov 2026 10:47:35 +0100 Subject: [PATCH 4/6] Use CakePHP native MariaDB driver in CI --- .github/workflows/ci.yml | 6 +++--- src/Db/Adapter/AdapterFactory.php | 1 + tests/TestCase/Db/Adapter/MysqlAdapterTest.php | 2 +- tests/TestCase/Migration/ManagerTest.php | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b1b98509..80044815c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -138,9 +138,9 @@ jobs: fi if [[ ${{ matrix.db-type }} == 'mariadb' ]]; then export DB='mysql' - export DB_URL='mysql://root:root@127.0.0.1/cakephp_test' - export DB_URL_COMPARE='mysql://root:root@127.0.0.1/cakephp_comparisons' - export DB_URL_SNAPSHOT='mysql://root:root@127.0.0.1/cakephp_snapshot' + export DB_URL='mariadb://root:root@127.0.0.1/cakephp_test' + export DB_URL_COMPARE='mariadb://root:root@127.0.0.1/cakephp_comparisons' + export DB_URL_SNAPSHOT='mariadb://root:root@127.0.0.1/cakephp_snapshot' fi if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB='mysql' diff --git a/src/Db/Adapter/AdapterFactory.php b/src/Db/Adapter/AdapterFactory.php index a4a81f136..8a838e45b 100644 --- a/src/Db/Adapter/AdapterFactory.php +++ b/src/Db/Adapter/AdapterFactory.php @@ -51,6 +51,7 @@ public static function instance(): static * @phpstan-var array|\Closure> */ protected array $adapters = [ + 'mariadb' => MysqlAdapter::class, 'mysql' => MysqlAdapter::class, 'postgres' => PostgresAdapter::class, 'sqlite' => SqliteAdapter::class, diff --git a/tests/TestCase/Db/Adapter/MysqlAdapterTest.php b/tests/TestCase/Db/Adapter/MysqlAdapterTest.php index f25fa3e07..3a3d2d944 100644 --- a/tests/TestCase/Db/Adapter/MysqlAdapterTest.php +++ b/tests/TestCase/Db/Adapter/MysqlAdapterTest.php @@ -42,7 +42,7 @@ class MysqlAdapterTest extends TestCase protected function setUp(): void { $config = ConnectionManager::getConfig('test'); - if ($config['scheme'] !== 'mysql') { + if (!in_array($config['scheme'], ['mysql', 'mariadb'], true)) { $this->markTestSkipped('Mysql tests disabled.'); } // Emulate the results of Util::parseDsn() diff --git a/tests/TestCase/Migration/ManagerTest.php b/tests/TestCase/Migration/ManagerTest.php index ecddc58a7..f2d6a2474 100644 --- a/tests/TestCase/Migration/ManagerTest.php +++ b/tests/TestCase/Migration/ManagerTest.php @@ -63,7 +63,7 @@ protected static function getDriverType(): string throw new RuntimeException('Cannot read configuration for test connection'); } - return $config['scheme']; + return $config['scheme'] === 'mariadb' ? 'mysql' : $config['scheme']; } protected function getOutput(): string From e988afbbf61366055fbb37803031323a557e1546 Mon Sep 17 00:00:00 2001 From: Jasper Smet Date: Mon, 9 Nov 2026 10:53:24 +0100 Subject: [PATCH 5/6] Keep existing PHPUnit reporting settings --- phpunit.xml.dist | 6 ------ 1 file changed, 6 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e96fa0de0..2a1f57dca 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,12 +3,6 @@ colors="true" cacheDirectory=".phpunit.cache" bootstrap="tests/bootstrap.php" - failOnDeprecation="true" - failOnPhpunitDeprecation="true" - failOnPhpunitNotice="true" - displayDetailsOnTestsThatTriggerDeprecations="true" - displayDetailsOnPhpunitDeprecations="true" - displayDetailsOnPhpunitNotices="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.1/phpunit.xsd" > From 716405e68124d42ba749e0fe201cafc500411db7 Mon Sep 17 00:00:00 2001 From: Jasper Smet Date: Mon, 16 Nov 2026 12:52:56 +0100 Subject: [PATCH 6/6] Separate MariaDB-specific migration adapter behavior --- src/Db/Adapter/AdapterFactory.php | 2 +- src/Db/Adapter/MariadbAdapter.php | 42 +++++++++++++++++++ src/Db/Adapter/MysqlAdapter.php | 36 +--------------- .../TestCase/Db/Adapter/MysqlAdapterTest.php | 24 +++++++---- 4 files changed, 60 insertions(+), 44 deletions(-) create mode 100644 src/Db/Adapter/MariadbAdapter.php diff --git a/src/Db/Adapter/AdapterFactory.php b/src/Db/Adapter/AdapterFactory.php index 8a838e45b..06370aa7a 100644 --- a/src/Db/Adapter/AdapterFactory.php +++ b/src/Db/Adapter/AdapterFactory.php @@ -51,7 +51,7 @@ public static function instance(): static * @phpstan-var array|\Closure> */ protected array $adapters = [ - 'mariadb' => MysqlAdapter::class, + 'mariadb' => MariadbAdapter::class, 'mysql' => MysqlAdapter::class, 'postgres' => PostgresAdapter::class, 'sqlite' => SqliteAdapter::class, diff --git a/src/Db/Adapter/MariadbAdapter.php b/src/Db/Adapter/MariadbAdapter.php new file mode 100644 index 000000000..1a6b7aa4a --- /dev/null +++ b/src/Db/Adapter/MariadbAdapter.php @@ -0,0 +1,42 @@ +quoteColumnName($constraintName)); + + return new AlterInstructions([$alter]); + } + + /** + * @inheritDoc + */ + protected function hasNativeUuid(): bool + { + // Avoid connecting when an adapter without a configured connection is used as a stub. + if (!$this->connection instanceof Connection || !$this->getOption('connection')) { + return false; + } + $version = $this->getConnection()->getDriver()->version(); + + return version_compare($version, '10.7', '>='); + } +} diff --git a/src/Db/Adapter/MysqlAdapter.php b/src/Db/Adapter/MysqlAdapter.php index d961255de..106a67106 100644 --- a/src/Db/Adapter/MysqlAdapter.php +++ b/src/Db/Adapter/MysqlAdapter.php @@ -1146,14 +1146,7 @@ protected function getAddCheckConstraintInstructions(TableMetadata $table, Check */ protected function getDropCheckConstraintInstructions(string $tableName, string $constraintName): AlterInstructions { - // MariaDB uses DROP CONSTRAINT, MySQL uses DROP CHECK - $keyword = $this->isMariaDb() ? 'CONSTRAINT' : 'CHECK'; - - $alter = sprintf( - 'DROP %s %s', - $keyword, - $this->quoteColumnName($constraintName), - ); + $alter = sprintf('DROP CHECK %s', $this->quoteColumnName($constraintName)); return new AlterInstructions([$alter]); } @@ -1573,37 +1566,12 @@ protected function getAddPartitionSql(PartitionDefinition $partition): string /** * Whether the server has a native uuid type. - * (MariaDB 10.7.0+) * * @return bool */ protected function hasNativeUuid(): bool { - // Prevent infinite connect() loop when MysqlAdapter is used as a stub. - if (!$this->connection instanceof Connection || !$this->getOption('connection')) { - return false; - } - $connection = $this->getConnection(); - $version = $connection->getDriver()->version(); - - return version_compare($version, '10.7', '>='); - } - - /** - * Whether the server is MariaDB (as opposed to MySQL). - * - * @return bool - */ - protected function isMariaDb(): bool - { - // Prevent infinite connect() loop when MysqlAdapter is used as a stub. - if (!$this->connection instanceof Connection || !$this->getOption('connection')) { - return false; - } - $connection = $this->getConnection(); - $version = $connection->getDriver()->version(); - - return stripos($version, 'mariadb') !== false; + return false; } /** diff --git a/tests/TestCase/Db/Adapter/MysqlAdapterTest.php b/tests/TestCase/Db/Adapter/MysqlAdapterTest.php index 3a3d2d944..b01f40267 100644 --- a/tests/TestCase/Db/Adapter/MysqlAdapterTest.php +++ b/tests/TestCase/Db/Adapter/MysqlAdapterTest.php @@ -12,6 +12,8 @@ use Cake\Database\Schema\TableSchema; use Cake\Datasource\ConnectionManager; use InvalidArgumentException; +use Migrations\Db\Adapter\AdapterFactory; +use Migrations\Db\Adapter\MariadbAdapter; use Migrations\Db\Adapter\MysqlAdapter; use Migrations\Db\Literal; use Migrations\Db\Table; @@ -47,11 +49,15 @@ protected function setUp(): void } // Emulate the results of Util::parseDsn() $this->config = [ - 'adapter' => 'mysql', + 'adapter' => $config['scheme'], 'connection' => ConnectionManager::get('test'), 'database' => $config['database'], ]; - $this->adapter = new MysqlAdapter($this->config, $this->getConsoleIo()); + $io = $this->getConsoleIo(); + $adapter = AdapterFactory::instance()->getAdapter($config['scheme'], $this->config); + assert($adapter instanceof MysqlAdapter); + $adapter->setIo($io); + $this->adapter = $adapter; // ensure the database is empty for each test $this->adapter->dropDatabase($this->config['database']); @@ -82,26 +88,25 @@ private function usingMysql8(): bool { $version = $this->adapter->getConnection()->getDriver()->version(); - return version_compare($version, '8.0.0', '>=') - && version_compare($version, '10.0.0', '<'); + return !$this->usingMariaDb() && version_compare($version, '8.0.0', '>='); } private function usingMariaDb(): bool { - $version = $this->adapter->getConnection()->getDriver()->version(); - - return str_contains($version, 'MariaDB') || version_compare($version, '10.0.0', '>='); + return $this->adapter instanceof MariadbAdapter; } private function usingMariaDbWithUuid(): bool { $version = $this->adapter->getConnection()->getDriver()->version(); - return version_compare($version, '10.7.0', '>='); + return $this->usingMariaDb() && version_compare($version, '10.7.0', '>='); } public function testConnection(): void { + $expectedClass = $this->config['adapter'] === 'mariadb' ? MariadbAdapter::class : MysqlAdapter::class; + $this->assertSame($expectedClass, $this->adapter::class); $this->assertInstanceOf(Connection::class, $this->adapter->getConnection()); } @@ -446,7 +451,8 @@ public function testCreateTableAndInheritDefaultCollation(): void 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', ]; - $adapter = new MysqlAdapter($options, $this->io); + $adapter = AdapterFactory::instance()->getAdapter($this->config['adapter'], $options); + $adapter->setIo($this->io); $table = new Table('table_with_default_collation', [], $adapter); $table->addColumn('name', 'string')