diff --git a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php index 33a0438f2f76587cc3df5b927d0fa2a469ef96d0..099ec96c49d586a411519344841e0af36823bcc4 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 318074ad50fce4fac056446bf605212b551d7f80..eba9f5a22ebe9e57c9bcf106687615330d65b302 100644 --- a/core/phpstan-baseline.neon +++ b/core/phpstan-baseline.neon @@ -1807,11 +1807,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