diff --git a/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentSourceWithHighWaterTest.php b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentSourceWithHighWaterTest.php index 290550cdb4..1813855f3f 100644 --- a/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentSourceWithHighWaterTest.php +++ b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentSourceWithHighWaterTest.php @@ -2,7 +2,11 @@ namespace Drupal\Tests\comment\Kernel\Plugin\migrate\source\d6; +use Drupal\Core\Database\Connection; +use Drupal\migrate\Plugin\migrate\id_map\Sql; +use Drupal\migrate\Plugin\MigrateIdMapInterface; use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; +use Prophecy\Argument; /** * Tests the Drupal 6 comment source w/ high water handling. @@ -18,6 +22,46 @@ class CommentSourceWithHighWaterTest extends MigrateSqlSourceTestBase { */ protected static $modules = ['comment', 'migrate_drupal']; + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + + // Ensure that \Drupal\migrate\Plugin\migrate\source\SqlBase::mapJoinable() + // considers the ID map plugin not joinable. + $connection = $this->prophesize(Connection::class); + $connection->getConnectionOptions()->willReturn([ + 'driver' => 'foo', + 'database' => 'bar', + ]); + + $id_map = $this->prophesize(Sql::class); + $id_map->getDatabase()->willReturn( + $connection->reveal() + ); + // Pretend the row with source ID 1 has already been imported; this is + // reflected in the high water mark. We consider none of the other rows + // imported, so those will return the empty array. + $id_map->getRowBySource(Argument::exact(['cid' => '1']))->willReturn([ + 'source_row_status' => MigrateIdMapInterface::STATUS_IMPORTED, + ]); + $id_map->getRowBySource(Argument::any())->willReturn([]); + // ::saveIdMapping() gets called when MigrateSourceTestBase::testSource() + // re-iterates over all rows while intentionally triggering a skip exception + // using migrate_skip_all_rows_test_migrate_prepare_row(). + $id_map->saveIdMapping( + Argument::any(), + Argument::any(), + Argument::exact(MigrateIdMapInterface::STATUS_IGNORED) + )->willReturn(); + // @todo This should not be necessary. + $id_map->delete(Argument::any(), Argument::any())->willReturn(); + $this->migration->getIdMap()->willReturn( + $id_map->reveal() + ); + } + /** * {@inheritdoc} */