Core and composer updates
This commit is contained in:
parent
a82634bb98
commit
62cac30480
1118 changed files with 21770 additions and 6306 deletions
|
@ -11,7 +11,7 @@ process:
|
|||
# the cid field to allow incremental migrations.
|
||||
cid: cid
|
||||
pid:
|
||||
plugin: migration
|
||||
plugin: migration_lookup
|
||||
migration: d6_comment
|
||||
source: pid
|
||||
entity_id: nid
|
||||
|
@ -32,7 +32,7 @@ process:
|
|||
thread: thread
|
||||
'comment_body/value': comment
|
||||
'comment_body/format':
|
||||
plugin: migration
|
||||
plugin: migration_lookup
|
||||
migration: d6_filter_format
|
||||
source: format
|
||||
destination:
|
||||
|
|
|
@ -11,7 +11,7 @@ process:
|
|||
# the cid field to allow incremental migrations.
|
||||
cid: cid
|
||||
pid:
|
||||
plugin: migration
|
||||
plugin: migration_lookup
|
||||
migration: d7_comment
|
||||
source: pid
|
||||
entity_id: nid
|
||||
|
|
|
@ -10,7 +10,7 @@ use Drupal\Core\Session\AnonymousUserSession;
|
|||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
use Drupal\simpletest\TestBase;
|
||||
use Drupal\Tests\Traits\Core\GeneratePermutationsTrait;
|
||||
use Drupal\user\Entity\Role;
|
||||
use Drupal\user\RoleInterface;
|
||||
|
||||
|
@ -23,6 +23,7 @@ use Drupal\user\RoleInterface;
|
|||
class CommentFieldAccessTest extends EntityKernelTestBase {
|
||||
|
||||
use CommentTestTrait;
|
||||
use GeneratePermutationsTrait;
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
|
@ -203,7 +204,7 @@ class CommentFieldAccessTest extends EntityKernelTestBase {
|
|||
'comment' => [$comment1, $comment2, $comment3, $comment4],
|
||||
'user' => [$comment_admin_user, $comment_enabled_user, $comment_no_edit_user, $comment_disabled_user, $anonymous_user]
|
||||
];
|
||||
$permutations = TestBase::generatePermutations($combinations);
|
||||
$permutations = $this->generatePermutations($combinations);
|
||||
|
||||
// Check access to administrative fields.
|
||||
foreach ($this->administrativeFields as $field) {
|
||||
|
|
|
@ -17,7 +17,7 @@ class MigrateCommentTest extends MigrateDrupal6TestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['comment'];
|
||||
public static $modules = ['comment', 'menu_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -11,6 +11,11 @@ use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
|||
*/
|
||||
class MigrateCommentVariableEntityDisplayTest extends MigrateCommentVariableDisplayBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['menu_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -11,6 +11,11 @@ use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
|||
*/
|
||||
class MigrateCommentVariableEntityFormDisplayTest extends MigrateCommentVariableDisplayBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['menu_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -15,7 +15,7 @@ class MigrateCommentVariableFieldTest extends MigrateDrupal6TestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['comment'];
|
||||
public static $modules = ['comment', 'menu_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -16,7 +16,7 @@ class MigrateCommentVariableInstanceTest extends MigrateDrupal6TestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['comment'];
|
||||
public static $modules = ['comment', 'menu_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -12,7 +12,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
|||
*/
|
||||
class MigrateCommentEntityDisplayTest extends MigrateDrupal7TestBase {
|
||||
|
||||
public static $modules = ['node', 'comment', 'text'];
|
||||
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -12,7 +12,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
|||
*/
|
||||
class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal7TestBase {
|
||||
|
||||
public static $modules = ['node', 'comment', 'text'];
|
||||
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -12,7 +12,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
|||
*/
|
||||
class MigrateCommentEntityFormDisplayTest extends MigrateDrupal7TestBase {
|
||||
|
||||
public static $modules = ['node', 'comment', 'text'];
|
||||
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -15,7 +15,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
|||
*/
|
||||
class MigrateCommentFieldInstanceTest extends MigrateDrupal7TestBase {
|
||||
|
||||
public static $modules = ['node', 'comment', 'text'];
|
||||
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -14,7 +14,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
|||
*/
|
||||
class MigrateCommentFieldTest extends MigrateDrupal7TestBase {
|
||||
|
||||
public static $modules = ['node', 'comment', 'text'];
|
||||
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -14,7 +14,7 @@ use Drupal\node\NodeInterface;
|
|||
*/
|
||||
class MigrateCommentTest extends MigrateDrupal7TestBase {
|
||||
|
||||
public static $modules = ['filter', 'node', 'comment', 'text'];
|
||||
public static $modules = ['filter', 'node', 'comment', 'text', 'menu_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -13,7 +13,7 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
|||
*/
|
||||
class MigrateCommentTypeTest extends MigrateDrupal7TestBase {
|
||||
|
||||
public static $modules = ['node', 'comment', 'text'];
|
||||
public static $modules = ['node', 'comment', 'text', 'menu_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
<?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 is the count returned by the query before the query
|
||||
// is modified by SqlBase::initializeIterator().
|
||||
$tests[0]['expected_count'] = 2;
|
||||
|
||||
$tests[0]['configuration']['high_water_property']['name'] = 'timestamp';
|
||||
$tests[0]['high_water'] = $tests[0]['source_data']['comments'][0]['timestamp'];
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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 {
|
||||
|
||||
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',
|
||||
],
|
||||
];
|
||||
class CommentTypeTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['node_type'] = [
|
||||
public static $modules = ['comment', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['node_type'] = [
|
||||
[
|
||||
'type' => 'article',
|
||||
'name' => 'Article',
|
||||
|
@ -55,7 +41,7 @@ class CommentTypeTest extends MigrateSqlSourceTestCase {
|
|||
'orig_type' => 'article',
|
||||
],
|
||||
];
|
||||
$this->databaseContents['field_config_instance'] = [
|
||||
$tests[0]['source_data']['field_config_instance'] = [
|
||||
[
|
||||
'id' => '14',
|
||||
'field_id' => '1',
|
||||
|
@ -66,7 +52,7 @@ class CommentTypeTest extends MigrateSqlSourceTestCase {
|
|||
'deleted' => '0',
|
||||
],
|
||||
];
|
||||
$this->databaseContents['variable'] = [
|
||||
$tests[0]['source_data']['variable'] = [
|
||||
[
|
||||
'name' => 'comment_default_mode_article',
|
||||
'value' => serialize(1),
|
||||
|
@ -92,7 +78,22 @@ class CommentTypeTest extends MigrateSqlSourceTestCase {
|
|||
'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;
|
||||
}
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@ use Drupal\comment\CommentLinkBuilder;
|
|||
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\simpletest\TestBase;
|
||||
use Drupal\Tests\Traits\Core\GeneratePermutationsTrait;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
|
@ -15,6 +15,8 @@ use Drupal\Tests\UnitTestCase;
|
|||
*/
|
||||
class CommentLinkBuilderTest extends UnitTestCase {
|
||||
|
||||
use GeneratePermutationsTrait;
|
||||
|
||||
/**
|
||||
* Comment manager mock.
|
||||
*
|
||||
|
@ -195,7 +197,7 @@ class CommentLinkBuilderTest extends UnitTestCase {
|
|||
'teaser', 'rss', 'full',
|
||||
],
|
||||
];
|
||||
$permutations = TestBase::generatePermutations($combinations);
|
||||
$permutations = $this->generatePermutations($combinations);
|
||||
foreach ($permutations as $combination) {
|
||||
$case = [
|
||||
$this->getMockNode(TRUE, $combination['comments'], $combination['form_location'], $combination['comment_count']),
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\comment\Unit\Migrate\d6;
|
||||
|
||||
/**
|
||||
* Tests D6 comment source plugin.
|
||||
*
|
||||
* @group comment
|
||||
*/
|
||||
class CommentTest extends CommentTestBase {
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue