diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c225747..80044815 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 @@ -139,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' @@ -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 83b2725e..f24d86e5 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 67461455..6a3d965e 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/src/Command/BakeMigrationDiffCommand.php b/src/Command/BakeMigrationDiffCommand.php index b57e9faa..5cddf0d6 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 9ab562d4..3c37f74d 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/AdapterFactory.php b/src/Db/Adapter/AdapterFactory.php index a4a81f13..06370aa7 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' => 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 00000000..1a6b7aa4 --- /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/MigrationsTableStorage.php b/src/Db/Adapter/MigrationsTableStorage.php index a859d262..5502d1fa 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/MysqlAdapter.php b/src/Db/Adapter/MysqlAdapter.php index d961255d..106a6710 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/src/Db/Adapter/PostgresAdapter.php b/src/Db/Adapter/PostgresAdapter.php index 84c3f180..4b92da69 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 9736f38f..e3710140 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 fab2cf68..35170d73 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/AdapterFactoryTest.php b/tests/TestCase/Db/Adapter/AdapterFactoryTest.php index e1fd1559..dfdae5bc 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/MysqlAdapterTest.php b/tests/TestCase/Db/Adapter/MysqlAdapterTest.php index 30a2c804..b01f4026 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; @@ -26,6 +28,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 { @@ -40,16 +44,20 @@ 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() $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']); @@ -80,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()); } @@ -444,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') @@ -2476,7 +2484,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 +2496,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 83138694..329580e8 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/RecordingAdapterTest.php b/tests/TestCase/Db/Adapter/RecordingAdapterTest.php index 248712ff..df6b1aff 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/Adapter/SqliteAdapterTest.php b/tests/TestCase/Db/Adapter/SqliteAdapterTest.php index 7471012d..5242f1d0 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 91dc7d0a..cdf63c4b 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 223609ad..9621c015 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/Db/Table/TableTest.php b/tests/TestCase/Db/Table/TableTest.php index 204cc9d6..d968a157 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 6f2dce7d..66f5871e 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 af3b7d04..1e311375 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 2628afa3..f2d6a247 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 @@ -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,9 @@ 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 +940,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 +972,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 +994,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 +1025,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 +2376,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 +2389,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 +2400,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 +2420,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'); diff --git a/tests/TestCase/TestCase.php b/tests/TestCase/TestCase.php index 50a6e240..6ab7c7c1 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 3a980440..da67b46a 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/comparisons/Diff/addRemove/schema-dump-test_comparisons_mysql.lock b/tests/comparisons/Diff/addRemove/schema-dump-test_comparisons_mysql.lock index 92a7ea8a..67a212b4 100644 Binary files a/tests/comparisons/Diff/addRemove/schema-dump-test_comparisons_mysql.lock and b/tests/comparisons/Diff/addRemove/schema-dump-test_comparisons_mysql.lock differ 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 c5f543d8..e47d30f9 100644 Binary files a/tests/comparisons/Diff/addRemove/schema-dump-test_comparisons_pgsql.lock and b/tests/comparisons/Diff/addRemove/schema-dump-test_comparisons_pgsql.lock differ diff --git a/tests/comparisons/Diff/decimalChange/schema-dump-test_comparisons_mysql.lock b/tests/comparisons/Diff/decimalChange/schema-dump-test_comparisons_mysql.lock index 292bb650..87db1245 100644 Binary files a/tests/comparisons/Diff/decimalChange/schema-dump-test_comparisons_mysql.lock and b/tests/comparisons/Diff/decimalChange/schema-dump-test_comparisons_mysql.lock differ diff --git a/tests/comparisons/Diff/default/schema-dump-test_comparisons_mysql.lock b/tests/comparisons/Diff/default/schema-dump-test_comparisons_mysql.lock index 5c1c96c1..d893496a 100644 Binary files a/tests/comparisons/Diff/default/schema-dump-test_comparisons_mysql.lock and b/tests/comparisons/Diff/default/schema-dump-test_comparisons_mysql.lock differ 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 6b5c22de..d3149324 100644 Binary files a/tests/comparisons/Diff/default/schema-dump-test_comparisons_pgsql.lock and b/tests/comparisons/Diff/default/schema-dump-test_comparisons_pgsql.lock differ diff --git a/tests/comparisons/Diff/simple/schema-dump-test_comparisons_mysql.lock b/tests/comparisons/Diff/simple/schema-dump-test_comparisons_mysql.lock index 056ae2be..b77c2183 100644 Binary files a/tests/comparisons/Diff/simple/schema-dump-test_comparisons_mysql.lock and b/tests/comparisons/Diff/simple/schema-dump-test_comparisons_mysql.lock differ 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 de631af6..28b98714 100644 Binary files a/tests/comparisons/Diff/simple/schema-dump-test_comparisons_pgsql.lock and b/tests/comparisons/Diff/simple/schema-dump-test_comparisons_pgsql.lock differ diff --git a/tests/comparisons/Diff/withAutoIdCompatibleSignedPrimaryKeys/schema-dump-test_comparisons_mysql.lock b/tests/comparisons/Diff/withAutoIdCompatibleSignedPrimaryKeys/schema-dump-test_comparisons_mysql.lock index be1e3fbb..6f5b9659 100644 Binary files a/tests/comparisons/Diff/withAutoIdCompatibleSignedPrimaryKeys/schema-dump-test_comparisons_mysql.lock and b/tests/comparisons/Diff/withAutoIdCompatibleSignedPrimaryKeys/schema-dump-test_comparisons_mysql.lock differ 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 be1e3fbb..6f5b9659 100644 Binary files a/tests/comparisons/Diff/withAutoIdIncompatibleSignedPrimaryKeys/schema-dump-test_comparisons_mysql.lock and b/tests/comparisons/Diff/withAutoIdIncompatibleSignedPrimaryKeys/schema-dump-test_comparisons_mysql.lock differ 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 b6cc0d71..da716ab7 100644 Binary files a/tests/comparisons/Diff/withAutoIdIncompatibleUnsignedPrimaryKeys/schema-dump-test_comparisons_mysql.lock and b/tests/comparisons/Diff/withAutoIdIncompatibleUnsignedPrimaryKeys/schema-dump-test_comparisons_mysql.lock differ 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 3229cd49..2f3fc858 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