From db7c533b64519f804cba420857837b35c374c477 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Mon, 29 Jan 2024 10:00:41 +0000 Subject: [PATCH] Issue #3417528 by longwave: Remove withConsecutive() in MigrateSqlIdMapEnsureTablesTest (cherry picked from commit e0f7856a4496cd4fb28cec696d252dbcdde64426) --- .../Unit/MigrateSqlIdMapEnsureTablesTest.php | 94 +++++++------------ core/phpstan-baseline.neon | 5 - 2 files changed, 32 insertions(+), 67 deletions(-) diff --git a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php index 33a0438f2f76..099ec96c49d5 100644 --- a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php @@ -117,75 +117,45 @@ public function testEnsureTablesNotExist() { ], ]; - $schema = $this->getMockBuilder('Drupal\Core\Database\Schema') - ->disableOriginalConstructor() - ->getMock(); - $schema->expects($this->exactly(2)) - ->method('tableExists') - ->willReturnMap([ - ['migrate_map_sql_idmap_test', FALSE], - ['migrate_message_sql_idmap_test', FALSE], - ]); - $schema->expects($this->exactly(2)) - ->method('createTable') - ->withConsecutive( - ['migrate_map_sql_idmap_test', $map_table_schema], - ['migrate_message_sql_idmap_test', $table_schema], - ); - - $this->runEnsureTablesTest($schema); + $schema = $this->prophesize('Drupal\Core\Database\Schema'); + $schema->tableExists('migrate_map_sql_idmap_test')->willReturn(FALSE); + $schema->tableExists('migrate_message_sql_idmap_test')->willReturn(FALSE); + $schema->createTable('migrate_map_sql_idmap_test', $map_table_schema)->shouldBeCalled(); + $schema->createTable('migrate_message_sql_idmap_test', $table_schema)->shouldBeCalled(); + $this->runEnsureTablesTest($schema->reveal()); } /** * Tests the ensureTables method when the tables exist. */ public function testEnsureTablesExist() { - $schema = $this->getMockBuilder('Drupal\Core\Database\Schema') - ->disableOriginalConstructor() - ->getMock(); - $schema->expects($this->exactly(1)) - ->method('tableExists') - ->with('migrate_map_sql_idmap_test') - ->willReturn(TRUE); - $schema->expects($this->exactly(3)) - ->method('fieldExists') - ->willReturnMap([ - ['migrate_map_sql_idmap_test', 'rollback_action', FALSE], - ['migrate_map_sql_idmap_test', 'hash', FALSE], - ['migrate_map_sql_idmap_test', 'source_ids_hash', FALSE], - ]); - $schema->expects($this->exactly(3)) - ->method('addField') - ->withConsecutive( - [ - 'migrate_map_sql_idmap_test', 'rollback_action', [ - 'type' => 'int', - 'size' => 'tiny', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Flag indicating what to do for this item on rollback', - ], - ], - [ - 'migrate_map_sql_idmap_test', 'hash', [ - 'type' => 'varchar', - 'length' => '64', - 'not null' => FALSE, - 'description' => 'Hash of source row data, for detecting changes', - ], - ], - [ - 'migrate_map_sql_idmap_test', 'source_ids_hash', [ - 'type' => 'varchar', - 'length' => '64', - 'not null' => TRUE, - 'description' => 'Hash of source ids. Used as primary key', - ], - ], - ); + $schema = $this->prophesize('Drupal\Core\Database\Schema'); + $schema->tableExists('migrate_map_sql_idmap_test')->willReturn(TRUE); + $schema->fieldExists('migrate_map_sql_idmap_test', 'rollback_action')->willReturn(FALSE); + $schema->fieldExists('migrate_map_sql_idmap_test', 'hash')->willReturn(FALSE); + $schema->fieldExists('migrate_map_sql_idmap_test', 'source_ids_hash')->willReturn(FALSE); + $schema->addField('migrate_map_sql_idmap_test', 'rollback_action', [ + 'type' => 'int', + 'size' => 'tiny', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'Flag indicating what to do for this item on rollback', + ])->shouldBeCalled(); + $schema->addField('migrate_map_sql_idmap_test', 'hash', [ + 'type' => 'varchar', + 'length' => '64', + 'not null' => FALSE, + 'description' => 'Hash of source row data, for detecting changes', + ])->shouldBeCalled(); + $schema->addField('migrate_map_sql_idmap_test', 'source_ids_hash', [ + 'type' => 'varchar', + 'length' => '64', + 'not null' => TRUE, + 'description' => 'Hash of source ids. Used as primary key', + ])->shouldBeCalled(); - $this->runEnsureTablesTest($schema); + $this->runEnsureTablesTest($schema->reveal()); } /** diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon index 6840667cb888..28eb86639d86 100644 --- a/core/phpstan-baseline.neon +++ b/core/phpstan-baseline.neon @@ -1853,11 +1853,6 @@ parameters: count: 1 path: modules/migrate/tests/src/Kernel/MigrateTestBase.php - - - message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#" - count: 2 - path: modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php - - message: "#^Variable \\$sub_process_plugins might not be defined\\.$#" count: 2 -- GitLab