diff -u b/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 --- b/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,30 +2,104 @@ namespace Drupal\Tests\comment\Kernel\Plugin\migrate\source\d6; +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; + /** * Tests the Drupal 6 comment source w/ high water handling. * * @covers \Drupal\comment\Plugin\migrate\source\d6\Comment + * * @group comment */ -class CommentSourceWithHighWaterTest extends CommentTestBase { +class CommentSourceWithHighWaterTest extends MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['comment', 'migrate_drupal']; /** * {@inheritdoc} */ public function providerSource() { - parent::providerSource(); + $tests = []; - $this->tests[0]['expected_count'] = NULL; - $this->tests[0]['configuration'] = [ - 'high_water_property' => [ - 'name' => 'timestamp', + // The source data. + $tests[0]['source_data']['comments'] = [ + [ + 'cid' => 1, + 'pid' => 0, + 'nid' => 2, + 'uid' => 3, + 'subject' => 'subject value 1', + 'comment' => 'comment value 1', + 'hostname' => 'hostname value 1', + 'timestamp' => 1382255613, + 'status' => 0, + 'thread' => '', + 'name' => '', + 'mail' => '', + 'homepage' => '', + 'format' => 'testformat1', + 'type' => 'story', + ], + [ + 'cid' => 2, + 'pid' => 1, + 'nid' => 3, + 'uid' => 4, + 'subject' => 'subject value 2', + 'comment' => 'comment value 2', + 'hostname' => 'hostname value 2', + 'timestamp' => 1382255662, + 'status' => 0, + 'thread' => '', + 'name' => '', + 'mail' => '', + 'homepage' => '', + 'format' => 'testformat2', + 'type' => 'page', ], ]; - $this->tests[0]['high_water'] = $this->tests[0]['source_data']['comments'][0]['timestamp']; - array_shift($this->tests[0]['expected_data']); - return $this->tests; + $tests[0]['source_data']['node'] = [ + [ + 'nid' => 2, + 'type' => 'story', + ], + [ + 'nid' => 3, + 'type' => 'page', + ], + ]; + + // The expected results. + $tests[0]['expected_data'] = [ + [ + 'cid' => 2, + 'pid' => 1, + 'nid' => 3, + 'uid' => 4, + 'subject' => 'subject value 2', + 'comment' => 'comment value 2', + 'hostname' => 'hostname value 2', + 'timestamp' => 1382255662, + 'status' => 1, + 'thread' => '', + 'name' => '', + 'mail' => '', + 'homepage' => '', + 'format' => 'testformat2', + 'type' => 'page', + ], + ]; + + // The expected count. + $tests[0]['expected_count'] = NULL; + + $tests[0]['configuration']['high_water_property']['name'] = 'timestamp'; + $tests[0]['high_water'] = $tests[0]['source_data']['comments'][0]['timestamp']; + return $tests; } } diff -u b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentTest.php b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentTest.php --- b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentTest.php +++ b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentTest.php @@ -2,17 +2,115 @@ namespace Drupal\Tests\comment\Kernel\Plugin\migrate\source\d6; +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; + /** * Tests D6 comment source plugin. * * @covers \Drupal\comment\Plugin\migrate\source\d6\Comment * @group comment */ -class CommentTest extends CommentTestBase { +class CommentTest extends MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['comment', 'migrate_drupal']; + /** + * {@inheritdoc} + */ public function providerSource() { - parent::providerSource(); - return $this->tests; + $tests = []; + + // The source data. + $tests[0]['source_data']['comments'] = [ + [ + 'cid' => 1, + 'pid' => 0, + 'nid' => 2, + 'uid' => 3, + 'subject' => 'subject value 1', + 'comment' => 'comment value 1', + 'hostname' => 'hostname value 1', + 'timestamp' => 1382255613, + 'status' => 0, + 'thread' => '', + 'name' => '', + 'mail' => '', + 'homepage' => '', + 'format' => 'testformat1', + 'type' => 'story', + ], + [ + 'cid' => 2, + 'pid' => 1, + 'nid' => 3, + 'uid' => 4, + 'subject' => 'subject value 2', + 'comment' => 'comment value 2', + 'hostname' => 'hostname value 2', + 'timestamp' => 1382255662, + 'status' => 0, + 'thread' => '', + 'name' => '', + 'mail' => '', + 'homepage' => '', + 'format' => 'testformat2', + 'type' => 'page', + ], + ]; + + $tests[0]['source_data']['node'] = [ + [ + 'nid' => 2, + 'type' => 'story', + ], + [ + 'nid' => 3, + 'type' => 'page', + ], + ]; + + // The expected results. + $tests[0]['expected_data'] = [ + [ + 'cid' => 1, + 'pid' => 0, + 'nid' => 2, + 'uid' => 3, + 'subject' => 'subject value 1', + 'comment' => 'comment value 1', + 'hostname' => 'hostname value 1', + 'timestamp' => 1382255613, + 'status' => 1, + 'thread' => '', + 'name' => '', + 'mail' => '', + 'homepage' => '', + 'format' => 'testformat1', + 'type' => 'story', + ], + [ + 'cid' => 2, + 'pid' => 1, + 'nid' => 3, + 'uid' => 4, + 'subject' => 'subject value 2', + 'comment' => 'comment value 2', + 'hostname' => 'hostname value 2', + 'timestamp' => 1382255662, + 'status' => 1, + 'thread' => '', + 'name' => '', + 'mail' => '', + 'homepage' => '', + 'format' => 'testformat2', + 'type' => 'page', + ], + ]; + + return $tests; } } reverted: --- b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentTestBase.php +++ /dev/null @@ -1,80 +0,0 @@ -tests = []; - - // The source data. - $this->tests[0]['source_data']['comments'] = [ - [ - 'cid' => 1, - 'pid' => 0, - 'nid' => 2, - 'uid' => 3, - 'subject' => 'subject value 1', - 'comment' => 'comment value 1', - 'hostname' => 'hostname value 1', - 'timestamp' => 1382255613, - 'status' => 0, - 'thread' => '', - 'name' => '', - 'mail' => '', - 'homepage' => '', - 'format' => 'testformat1', - 'type' => 'story', - ], - [ - 'cid' => 2, - 'pid' => 1, - 'nid' => 3, - 'uid' => 4, - 'subject' => 'subject value 2', - 'comment' => 'comment value 2', - 'hostname' => 'hostname value 2', - 'timestamp' => 1382255662, - 'status' => 0, - 'thread' => '', - 'name' => '', - 'mail' => '', - 'homepage' => '', - 'format' => 'testformat2', - 'type' => 'page', - ], - ]; - $this->tests[0]['source_data']['node'] = [ - [ - 'nid' => 2, - 'type' => 'story' - ], - [ - 'nid' => 3, - 'type' => 'page' - ], - ]; - - // The expected results. - $this->tests[0]['expected_data'] = $this->tests[0]['source_data']['comments']; - foreach ( $this->tests[0]['expected_data'] as $k => $row) { - $this->tests[0]['expected_data'][$k]['status'] = 1; - } - - } -} diff -u b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentVariablePerCommentTypeTest.php b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentVariablePerCommentTypeTest.php --- b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentVariablePerCommentTypeTest.php +++ b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentVariablePerCommentTypeTest.php @@ -30,7 +30,7 @@ ], [ 'type' => 'story', - ] + ], ]; $tests[0]['source_data']['variable'] = [ diff -u b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentVariableTest.php b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentVariableTest.php --- b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentVariableTest.php +++ b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentVariableTest.php @@ -5,7 +5,7 @@ use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; /** - * Tests comment variable source plugin. + * Tests d6_comment_variable source plugin. * * @covers \Drupal\comment\Plugin\migrate\source\d6\CommentVariable * @group comment @@ -29,6 +29,7 @@ 'type' => 'page', ], ]; + $tests[0]['source_data']['variable'] = [ [ 'name' => 'comment_page', diff -u b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d7/CommentTest.php b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d7/CommentTest.php --- b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d7/CommentTest.php +++ b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d7/CommentTest.php @@ -11,6 +11,7 @@ * @group comment */ class CommentTest extends MigrateSqlSourceTestBase { + /** * {@inheritdoc} */ @@ -85,11 +86,28 @@ ]; // The expected results. - $tests[0]['expected_data'] = $tests[0]['source_data']['comment']; - $tests[0]['expected_data'][0]['comment_body'] = [ + $tests[0]['expected_data'] = [ [ - 'value' => 'This is a comment', - 'format' => 'filtered_html', + 'cid' => '1', + 'pid' => '0', + 'nid' => '1', + 'uid' => '1', + 'subject' => 'A comment', + 'hostname' => '::1', + 'created' => '1421727536', + 'changed' => '1421727536', + 'status' => '1', + 'thread' => '01/', + 'name' => 'admin', + 'mail' => '', + 'homepage' => '', + 'language' => 'und', + 'comment_body' => [ + [ + 'value' => 'This is a comment', + 'format' => 'filtered_html', + ], + ], ], ]; diff -u b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d7/CommentTypeTest.php b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d7/CommentTypeTest.php --- b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d7/CommentTypeTest.php +++ b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d7/CommentTypeTest.php @@ -50,7 +50,7 @@ 'bundle' => 'comment_node_article', 'data' => 'a:0:{}', 'deleted' => '0', - ] + ], ]; $tests[0]['source_data']['variable'] = [ [ @@ -91,7 +91,7 @@ 'preview' => '0', 'subject' => '1', 'label' => 'Article comment', - ] + ], ]; return $tests; } diff -u b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php --- b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php +++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php @@ -216,7 +216,6 @@ $high_water_field = $this->getHighWaterField(); $conditions->condition($high_water_field, $high_water, '>'); $this->query->orderBy($high_water_field); - $condition_added = TRUE; } if ($condition_added) { $this->query->condition($conditions); @@ -278,6 +277,7 @@ $high_water_field = $this->getHighWaterField(); $conditions->condition($high_water_field, $high_water, '>'); $this->query->orderBy($high_water_field); + $condition_added = TRUE; } if ($condition_added) { $this->query->condition($conditions);