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 new file mode 100644 index 0000000000000000000000000000000000000000..27fb068a693f5e5e8f2d894bac8d5e98533ab3f4 --- /dev/null +++ b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentSourceWithHighWaterTest.php @@ -0,0 +1,105 @@ +<?php + +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 MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['comment', 'migrate_drupal']; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $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' => 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 --git a/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 new file mode 100644 index 0000000000000000000000000000000000000000..0372f0f9ac06088b9d8d71552d69a3fd0e96bd9c --- /dev/null +++ b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentTest.php @@ -0,0 +1,116 @@ +<?php + +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 MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['comment', 'migrate_drupal']; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $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; + } + +} diff --git a/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 new file mode 100644 index 0000000000000000000000000000000000000000..dd1b1fd06c6dfd363a877f4800b04c813d50eb50 --- /dev/null +++ b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentVariablePerCommentTypeTest.php @@ -0,0 +1,62 @@ +<?php + +namespace Drupal\Tests\comment\Kernel\Plugin\migrate\source\d6; + +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; + +/** + * Tests comment variable per comment type source plugin. + * + * @covers \Drupal\comment\Plugin\migrate\source\d6\CommentVariablePerCommentType + * @group comment + */ +class CommentVariablePerCommentTypeTest extends MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['comment', 'migrate_drupal']; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $tests = []; + + // The source data. + $tests[0]['source_data']['node_type'] = [ + [ + 'type' => 'page', + ], + [ + 'type' => 'story', + ], + ]; + + $tests[0]['source_data']['variable'] = [ + [ + 'name' => 'comment_subject_field_page', + 'value' => serialize(1), + ], + [ + 'name' => 'comment_subject_field_story', + 'value' => serialize(0), + ], + ]; + + // The expected results. + // Each result will also include a label and description, but those are + // static values set by the source plugin and don't need to be asserted. + $tests[0]['expected_data'] = [ + [ + 'comment_type' => 'comment', + ], + [ + 'comment_type' => 'comment_no_subject', + ], + ]; + + return $tests; + } + +} diff --git a/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 new file mode 100644 index 0000000000000000000000000000000000000000..a84c776b770c21000ceebd5ac42d89e89dad3b02 --- /dev/null +++ b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentVariableTest.php @@ -0,0 +1,92 @@ +<?php + +namespace Drupal\Tests\comment\Kernel\Plugin\migrate\source\d6; + +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; + +/** + * Tests d6_comment_variable source plugin. + * + * @covers \Drupal\comment\Plugin\migrate\source\d6\CommentVariable + * @group comment + */ +class CommentVariableTest extends MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['comment', 'migrate_drupal']; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $tests = []; + + // The source data. + $tests[0]['source_data']['node_type'] = [ + [ + 'type' => 'page', + ], + ]; + + $tests[0]['source_data']['variable'] = [ + [ + 'name' => 'comment_page', + 'value' => serialize(1), + ], + [ + 'name' => 'comment_default_mode_page', + 'value' => serialize(1), + ], + [ + 'name' => 'comment_default_order_page', + 'value' => serialize(1), + ], + [ + 'name' => 'comment_default_per_page_page', + 'value' => serialize(50), + ], + [ + 'name' => 'comment_controls_page', + 'value' => serialize(1), + ], + [ + 'name' => 'comment_anonymous_page', + 'value' => serialize(1), + ], + [ + 'name' => 'comment_subject_field_page', + 'value' => serialize(1), + ], + [ + 'name' => 'comment_preview_page', + 'value' => serialize(1), + ], + [ + 'name' => 'comment_form_location_page', + 'value' => serialize(1), + ], + ]; + + // The expected results. + $tests[0]['expected_data'] = [ + [ + 'comment' => '1', + 'comment_default_mode' => '1', + 'comment_default_order' => '1', + 'comment_default_per_page' => '50', + 'comment_controls' => '1', + 'comment_anonymous' => '1', + 'comment_subject_field' => '1', + 'comment_preview' => '1', + 'comment_form_location' => '1', + 'node_type' => 'page', + 'comment_type' => 'comment', + ], + ]; + + return $tests; + } + +} diff --git a/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 new file mode 100644 index 0000000000000000000000000000000000000000..9d9760bf905901dd85c906089b43fc905dfd1710 --- /dev/null +++ b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d7/CommentTest.php @@ -0,0 +1,117 @@ +<?php + +namespace Drupal\Tests\comment\Kernel\Plugin\migrate\source\d7; + +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; + +/** + * Tests D7 comment source plugin. + * + * @covers \Drupal\comment\Plugin\migrate\source\d7\Comment + * @group comment + */ +class CommentTest extends MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['comment', 'migrate_drupal']; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $tests = []; + + // The source data. + $tests[0]['source_data']['comment'] = [ + [ + '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', + ], + ]; + $tests[0]['source_data']['node'] = [ + [ + 'nid' => '1', + 'vid' => '1', + 'type' => 'test_content_type', + 'language' => 'en', + 'title' => 'A Node', + 'uid' => '1', + 'status' => '1', + 'created' => '1421727515', + 'changed' => '1421727515', + 'comment' => '2', + 'promote' => '1', + 'sticky' => '0', + 'tnid' => '0', + 'translate' => '0', + ], + ]; + $tests[0]['source_data']['field_config_instance'] = [ + [ + 'id' => '14', + 'field_id' => '1', + 'field_name' => 'comment_body', + 'entity_type' => 'comment', + 'bundle' => 'comment_node_test_content_type', + 'data' => 'a:0:{}', + 'deleted' => '0', + ], + ]; + $tests[0]['source_data']['field_data_comment_body'] = [ + [ + 'entity_type' => 'comment', + 'bundle' => 'comment_node_test_content_type', + 'deleted' => '0', + 'entity_id' => '1', + 'revision_id' => '1', + 'language' => 'und', + 'delta' => '0', + 'comment_body_value' => 'This is a comment', + 'comment_body_format' => 'filtered_html', + ], + ]; + + // The expected results. + $tests[0]['expected_data'] = [ + [ + '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', + ], + ], + ], + ]; + + return $tests; + } + +} diff --git a/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTypeTest.php b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d7/CommentTypeTest.php similarity index 60% rename from core/modules/comment/tests/src/Unit/Migrate/d7/CommentTypeTest.php rename to core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d7/CommentTypeTest.php index 106716d8f27df6b1c1bb2211caff70cdaba901d2..11f3db58421dc4911723aa66adbcf9b55be98030 100644 --- a/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTypeTest.php +++ b/core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d7/CommentTypeTest.php @@ -1,44 +1,30 @@ <?php -namespace Drupal\Tests\comment\Unit\Migrate\d7; +namespace Drupal\Tests\comment\Kernel\Plugin\migrate\source\d7; -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; /** * Tests D7 comment type source plugin. * + * @covers \Drupal\comment\Plugin\migrate\source\d7\CommentType * @group comment */ -class CommentTypeTest extends MigrateSqlSourceTestCase { +class CommentTypeTest extends MigrateSqlSourceTestBase { - const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d7\CommentType'; - - protected $migrationConfiguration = [ - 'id' => 'test', - 'source' => [ - 'plugin' => 'd7_comment_type', - ], - ]; - - protected $expectedResults = [ - [ - 'bundle' => 'comment_node_article', - 'node_type' => 'article', - 'default_mode' => '1', - 'per_page' => '50', - 'anonymous' => '0', - 'form_location' => '1', - 'preview' => '0', - 'subject' => '1', - 'label' => 'Article comment', - ], - ]; + /** + * {@inheritdoc} + */ + public static $modules = ['comment', 'migrate_drupal']; /** * {@inheritdoc} */ - protected function setUp() { - $this->databaseContents['node_type'] = [ + public function providerSource() { + $tests = []; + + // The source data. + $tests[0]['source_data']['node_type'] = [ [ 'type' => 'article', 'name' => 'Article', @@ -55,7 +41,7 @@ protected function setUp() { 'orig_type' => 'article', ], ]; - $this->databaseContents['field_config_instance'] = [ + $tests[0]['source_data']['field_config_instance'] = [ [ 'id' => '14', 'field_id' => '1', @@ -66,7 +52,7 @@ protected function setUp() { 'deleted' => '0', ], ]; - $this->databaseContents['variable'] = [ + $tests[0]['source_data']['variable'] = [ [ 'name' => 'comment_default_mode_article', 'value' => serialize(1), @@ -92,7 +78,22 @@ protected function setUp() { 'value' => serialize(1), ], ]; - parent::setUp(); + + // The expected results. + $tests[0]['expected_data'] = [ + [ + 'bundle' => 'comment_node_article', + 'node_type' => 'article', + 'default_mode' => '1', + 'per_page' => '50', + 'anonymous' => '0', + 'form_location' => '1', + 'preview' => '0', + 'subject' => '1', + 'label' => 'Article comment', + ], + ]; + return $tests; } } diff --git a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentSourceWithHighWaterTest.php b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentSourceWithHighWaterTest.php deleted file mode 100644 index b2cbaa7bb6909b8154c22d3f5ddd8ecb878a8a3b..0000000000000000000000000000000000000000 --- a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentSourceWithHighWaterTest.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -namespace Drupal\Tests\comment\Unit\Migrate\d6; - -/** - * Tests the Drupal 6 comment source w/ high water handling. - * - * @group comment - */ -class CommentSourceWithHighWaterTest extends CommentTestBase { - - const ORIGINAL_HIGH_WATER = 1382255613; - - /** - * {@inheritdoc} - */ - protected function setUp() { - $this->migrationConfiguration['source']['high_water_property']['name'] = 'timestamp'; - array_shift($this->expectedResults); - parent::setUp(); - } - -} diff --git a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentTest.php b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentTest.php deleted file mode 100644 index 2056d24607ec930714ebbb1e8a419713cb527bd0..0000000000000000000000000000000000000000 --- a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentTest.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -namespace Drupal\Tests\comment\Unit\Migrate\d6; - -/** - * Tests D6 comment source plugin. - * - * @group comment - */ -class CommentTest extends CommentTestBase { - -} diff --git a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentTestBase.php b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentTestBase.php deleted file mode 100644 index 220328be00517d0059b439b23cfa6ba58c080381..0000000000000000000000000000000000000000 --- a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentTestBase.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php - -namespace Drupal\Tests\comment\Unit\Migrate\d6; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * Base class for comment source unit tests. - */ -abstract class CommentTestBase extends MigrateSqlSourceTestCase { - - // The plugin system is not working during unit testing so the source plugin - // class needs to be manually specified. - const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d6\Comment'; - - // The fake Migration configuration entity. - protected $migrationConfiguration = [ - // The ID of the entity, can be any string. - 'id' => 'test', - // This needs to be the identifier of the actual key: cid for comment, nid - // for node and so on. - 'source' => [ - 'plugin' => 'd6_comment', - ], - ]; - - // We need to set up the database contents; it's easier to do that below. - - protected $expectedResults = [ - [ - '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', - ], - ]; - - /** - * {@inheritdoc} - */ - protected function setUp() { - foreach ($this->expectedResults as $k => $row) { - $this->databaseContents['comments'][$k] = $row; - $this->databaseContents['comments'][$k]['status'] = 1 - $this->databaseContents['comments'][$k]['status']; - } - // Add node table data. - $this->databaseContents['node'][] = ['nid' => 2, 'type' => 'story']; - $this->databaseContents['node'][] = ['nid' => 3, 'type' => 'page']; - parent::setUp(); - } - -} diff --git a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariablePerCommentTypeTest.php b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariablePerCommentTypeTest.php deleted file mode 100644 index 892319a18eda1f6b36fea2192ead570014dc3ea7..0000000000000000000000000000000000000000 --- a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariablePerCommentTypeTest.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php - -namespace Drupal\Tests\comment\Unit\Migrate\d6; - -use Drupal\comment\Plugin\migrate\source\d6\CommentVariablePerCommentType; -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * @coversDefaultClass \Drupal\comment\Plugin\migrate\source\d6\CommentVariablePerCommentType - * @group comment - */ -class CommentVariablePerCommentTypeTest extends MigrateSqlSourceTestCase { - - const PLUGIN_CLASS = CommentVariablePerCommentType::class; - - protected $migrationConfiguration = [ - 'id' => 'test', - 'source' => [ - 'plugin' => 'd6_comment_variable_per_comment_type', - ], - ]; - - protected $expectedResults = [ - // Each result will also include a label and description, but those are - // static values set by the source plugin and don't need to be asserted. - [ - 'comment_type' => 'comment', - ], - [ - 'comment_type' => 'comment_no_subject', - ], - ]; - - /** - * {@inheritdoc} - */ - protected function setUp() { - $this->databaseContents['node_type'] = [ - [ - 'type' => 'page', - ], - [ - 'type' => 'story', - ], - ]; - $this->databaseContents['variable'] = [ - [ - 'name' => 'comment_subject_field_page', - 'value' => serialize(1), - ], - [ - 'name' => 'comment_subject_field_story', - 'value' => serialize(0), - ], - ]; - parent::setUp(); - } - -} diff --git a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariableTest.php b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariableTest.php deleted file mode 100644 index 406cd11f6f2bd763795937aad7347d6b0f462de9..0000000000000000000000000000000000000000 --- a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariableTest.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php - -namespace Drupal\Tests\comment\Unit\Migrate\d6; - -use Drupal\comment\Plugin\migrate\source\d6\CommentVariable; -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * @coversDefaultClass \Drupal\comment\Plugin\migrate\source\d6\CommentVariable - * @group comment - */ -class CommentVariableTest extends MigrateSqlSourceTestCase { - - const PLUGIN_CLASS = CommentVariable::class; - - protected $migrationConfiguration = [ - 'id' => 'test', - 'source' => [ - 'plugin' => 'd6_comment_variable', - ], - ]; - - protected $expectedResults = [ - [ - 'comment' => '1', - 'comment_default_mode' => '1', - 'comment_default_order' => '1', - 'comment_default_per_page' => '50', - 'comment_controls' => '1', - 'comment_anonymous' => '1', - 'comment_subject_field' => '1', - 'comment_preview' => '1', - 'comment_form_location' => '1', - 'node_type' => 'page', - 'comment_type' => 'comment', - ], - ]; - - /** - * {@inheritdoc} - */ - protected function setUp() { - $this->databaseContents['node_type'] = [ - [ - 'type' => 'page', - ], - ]; - $this->databaseContents['variable'] = [ - [ - 'name' => 'comment_page', - 'value' => serialize(1), - ], - [ - 'name' => 'comment_default_mode_page', - 'value' => serialize(1), - ], - [ - 'name' => 'comment_default_order_page', - 'value' => serialize(1), - ], - [ - 'name' => 'comment_default_per_page_page', - 'value' => serialize(50), - ], - [ - 'name' => 'comment_controls_page', - 'value' => serialize(1), - ], - [ - 'name' => 'comment_anonymous_page', - 'value' => serialize(1), - ], - [ - 'name' => 'comment_subject_field_page', - 'value' => serialize(1), - ], - [ - 'name' => 'comment_preview_page', - 'value' => serialize(1), - ], - [ - 'name' => 'comment_form_location_page', - 'value' => serialize(1), - ], - ]; - parent::setUp(); - } - -} diff --git a/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTest.php b/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTest.php deleted file mode 100644 index aed2f285504abd3956b4ae5cea4e445b29388dc5..0000000000000000000000000000000000000000 --- a/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTest.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php - -namespace Drupal\Tests\comment\Unit\Migrate\d7; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * Tests D7 comment source plugin. - * - * @group comment - */ -class CommentTest extends MigrateSqlSourceTestCase { - - const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d7\Comment'; - - protected $migrationConfiguration = [ - 'id' => 'test', - 'source' => [ - 'plugin' => 'd7_comment', - ], - ]; - - protected $expectedResults = [ - [ - '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', - ], - ], - ], - ]; - - /** - * {@inheritdoc} - */ - protected function setUp() { - $this->databaseContents['comment'] = $this->expectedResults; - unset($this->databaseContents['comment'][0]['comment_body']); - - $this->databaseContents['node'] = [ - [ - 'nid' => '1', - 'vid' => '1', - 'type' => 'test_content_type', - 'language' => 'en', - 'title' => 'A Node', - 'uid' => '1', - 'status' => '1', - 'created' => '1421727515', - 'changed' => '1421727515', - 'comment' => '2', - 'promote' => '1', - 'sticky' => '0', - 'tnid' => '0', - 'translate' => '0', - ], - ]; - $this->databaseContents['field_config_instance'] = [ - [ - 'id' => '14', - 'field_id' => '1', - 'field_name' => 'comment_body', - 'entity_type' => 'comment', - 'bundle' => 'comment_node_test_content_type', - 'data' => 'a:0:{}', - 'deleted' => '0', - ], - ]; - $this->databaseContents['field_data_comment_body'] = [ - [ - 'entity_type' => 'comment', - 'bundle' => 'comment_node_test_content_type', - 'deleted' => '0', - 'entity_id' => '1', - 'revision_id' => '1', - 'language' => 'und', - 'delta' => '0', - 'comment_body_value' => 'This is a comment', - 'comment_body_format' => 'filtered_html', - ], - ]; - parent::setUp(); - } - -}