updated core to 8.6.3
This commit is contained in:
@@ -10,9 +10,9 @@ use Drupal\comment\Tests\CommentTestTrait;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\field_ui\Tests\FieldUiTestTrait;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Tests\field_ui\Traits\FieldUiTestTrait;
|
||||
use Drupal\user\RoleInterface;
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@ class CommentHalJsonAnonTest extends CommentHalJsonTestBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Anononymous users cannot edit their own comments.
|
||||
* Anonymous users cannot edit their own comments.
|
||||
*
|
||||
* @see \Drupal\comment\CommentAccessControlHandler::checkAccess
|
||||
*
|
||||
|
||||
@@ -24,7 +24,7 @@ class CommentJsonAnonTest extends CommentResourceTestBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Anononymous users cannot edit their own comments.
|
||||
* Anonymous users cannot edit their own comments.
|
||||
*
|
||||
* @see \Drupal\comment\CommentAccessControlHandler::checkAccess
|
||||
*
|
||||
|
||||
@@ -60,7 +60,7 @@ abstract class CommentResourceTestBase extends EntityResourceTestBase {
|
||||
$this->grantPermissionsToTestedRole(['post comments']);
|
||||
break;
|
||||
case 'PATCH':
|
||||
// Anononymous users are not ever allowed to edit their own comments. To
|
||||
// Anonymous users are not ever allowed to edit their own comments. To
|
||||
// be able to test PATCHing comments as the anonymous user, the more
|
||||
// permissive 'administer comments' permission must be granted.
|
||||
// @see \Drupal\comment\CommentAccessControlHandler::checkAccess
|
||||
|
||||
@@ -26,7 +26,7 @@ class CommentXmlAnonTest extends CommentResourceTestBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Anononymous users cannot edit their own comments.
|
||||
* Anonymous users cannot edit their own comments.
|
||||
*
|
||||
* @see \Drupal\comment\CommentAccessControlHandler::checkAccess
|
||||
*
|
||||
|
||||
@@ -20,7 +20,12 @@ class MigrateCommentTest extends MigrateDrupal6TestBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['comment', 'menu_ui'];
|
||||
public static $modules = [
|
||||
'comment',
|
||||
'content_translation',
|
||||
'language',
|
||||
'menu_ui',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -31,6 +36,7 @@ class MigrateCommentTest extends MigrateDrupal6TestBase {
|
||||
$this->installEntitySchema('node');
|
||||
$this->installEntitySchema('comment');
|
||||
$this->installSchema('comment', ['comment_entity_statistics']);
|
||||
$this->installSchema('node', ['node_access']);
|
||||
$this->installConfig(['comment']);
|
||||
|
||||
// The entity.node.canonical route must exist when the RDF hook is called.
|
||||
@@ -38,7 +44,10 @@ class MigrateCommentTest extends MigrateDrupal6TestBase {
|
||||
|
||||
$this->migrateContent();
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd6_language_content_settings',
|
||||
'd6_node',
|
||||
'd6_node_translation',
|
||||
'd6_comment_type',
|
||||
'd6_comment_field',
|
||||
'd6_comment_field_instance',
|
||||
@@ -84,6 +93,31 @@ class MigrateCommentTest extends MigrateDrupal6TestBase {
|
||||
$node = $comment->getCommentedEntity();
|
||||
$this->assertInstanceOf(NodeInterface::class, $node);
|
||||
$this->assertSame('1', $node->id());
|
||||
|
||||
// Tests that the language of the comment is migrated from the node.
|
||||
$comment = Comment::load(7);
|
||||
$this->assertSame('Comment to John Smith - EN', $comment->subject->value);
|
||||
$this->assertSame('This is an English comment.', $comment->comment_body->value);
|
||||
$this->assertSame('21', $comment->getCommentedEntityId());
|
||||
$this->assertSame('node', $comment->getCommentedEntityTypeId());
|
||||
$this->assertSame('en', $comment->language()->getId());
|
||||
|
||||
$node = $comment->getCommentedEntity();
|
||||
$this->assertInstanceOf(NodeInterface::class, $node);
|
||||
$this->assertSame('21', $node->id());
|
||||
|
||||
// Tests that the comment language is correct and that the commented entity
|
||||
// is correctly migrated when the comment was posted to a node translation.
|
||||
$comment = Comment::load(8);
|
||||
$this->assertSame('Comment to John Smith - FR', $comment->subject->value);
|
||||
$this->assertSame('This is a French comment.', $comment->comment_body->value);
|
||||
$this->assertSame('21', $comment->getCommentedEntityId());
|
||||
$this->assertSame('node', $comment->getCommentedEntityTypeId());
|
||||
$this->assertSame('fr', $comment->language()->getId());
|
||||
|
||||
$node = $comment->getCommentedEntity();
|
||||
$this->assertInstanceOf(NodeInterface::class, $node);
|
||||
$this->assertSame('21', $node->id());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,11 +19,15 @@ class MigrateCommentTest extends MigrateDrupal7TestBase {
|
||||
*/
|
||||
public static $modules = [
|
||||
'comment',
|
||||
'content_translation',
|
||||
'datetime',
|
||||
'filter',
|
||||
'image',
|
||||
'language',
|
||||
'link',
|
||||
'menu_ui',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
'node',
|
||||
'taxonomy',
|
||||
'telephone',
|
||||
@@ -38,14 +42,19 @@ class MigrateCommentTest extends MigrateDrupal7TestBase {
|
||||
|
||||
$this->installEntitySchema('node');
|
||||
$this->installEntitySchema('comment');
|
||||
$this->installEntitySchema('taxonomy_term');
|
||||
$this->installConfig(['comment', 'node']);
|
||||
$this->installSchema('comment', ['comment_entity_statistics']);
|
||||
|
||||
$this->installSchema('node', ['node_access']);
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd7_node_type',
|
||||
'd7_language_content_settings',
|
||||
'd7_user_role',
|
||||
'd7_user',
|
||||
'd7_node_type',
|
||||
'd7_node',
|
||||
'd7_node_translation',
|
||||
'd7_comment_type',
|
||||
'd7_comment_field',
|
||||
'd7_comment_field_instance',
|
||||
@@ -55,6 +64,8 @@ class MigrateCommentTest extends MigrateDrupal7TestBase {
|
||||
'd7_field',
|
||||
'd7_field_instance',
|
||||
'd7_comment',
|
||||
'd7_entity_translation_settings',
|
||||
'd7_comment_entity_translation',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -64,7 +75,7 @@ class MigrateCommentTest extends MigrateDrupal7TestBase {
|
||||
public function testMigration() {
|
||||
$comment = Comment::load(1);
|
||||
$this->assertInstanceOf(Comment::class, $comment);
|
||||
$this->assertSame('A comment', $comment->getSubject());
|
||||
$this->assertSame('Subject field in English', $comment->getSubject());
|
||||
$this->assertSame('1421727536', $comment->getCreatedTime());
|
||||
$this->assertSame('1421727536', $comment->getChangedTime());
|
||||
$this->assertTrue($comment->getStatus());
|
||||
@@ -73,6 +84,7 @@ class MigrateCommentTest extends MigrateDrupal7TestBase {
|
||||
$this->assertSame('This is a comment', $comment->comment_body->value);
|
||||
$this->assertSame('filtered_html', $comment->comment_body->format);
|
||||
$this->assertSame('2001:db8:ffff:ffff:ffff:ffff:ffff:ffff', $comment->getHostname());
|
||||
$this->assertSame('en', $comment->language()->getId());
|
||||
$this->assertSame('1000000', $comment->field_integer->value);
|
||||
|
||||
$node = $comment->getCommentedEntity();
|
||||
@@ -85,6 +97,59 @@ class MigrateCommentTest extends MigrateDrupal7TestBase {
|
||||
$this->assertInstanceOf(Comment::class, $comment);
|
||||
$this->assertSame('TNG for the win!', $comment->getSubject());
|
||||
$this->assertSame('TNG is better than DS9.', $comment->comment_body->value);
|
||||
$this->assertSame('en', $comment->language()->getId());
|
||||
|
||||
// Tests that the commented entity is correctly migrated when the comment
|
||||
// was posted to a node translation.
|
||||
$comment = Comment::load(3);
|
||||
$this->assertInstanceOf(Comment::class, $comment);
|
||||
$this->assertSame('Comment to IS translation', $comment->getSubject());
|
||||
$this->assertSame('This is a comment to an Icelandic translation.', $comment->comment_body->value);
|
||||
$this->assertSame('2', $comment->getCommentedEntityId());
|
||||
$this->assertSame('node', $comment->getCommentedEntityTypeId());
|
||||
$this->assertSame('is', $comment->language()->getId());
|
||||
|
||||
$node = $comment->getCommentedEntity();
|
||||
$this->assertInstanceOf(NodeInterface::class, $node);
|
||||
$this->assertSame('2', $node->id());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the migration of comment entity translations.
|
||||
*/
|
||||
public function testCommentEntityTranslations() {
|
||||
$manager = $this->container->get('content_translation.manager');
|
||||
|
||||
// Get the comment and its translations.
|
||||
$comment = Comment::load(1);
|
||||
$comment_fr = $comment->getTranslation('fr');
|
||||
$comment_is = $comment->getTranslation('is');
|
||||
|
||||
// Test that fields translated with Entity Translation are migrated.
|
||||
$this->assertSame('Subject field in English', $comment->getSubject());
|
||||
$this->assertSame('Subject field in French', $comment_fr->getSubject());
|
||||
$this->assertSame('Subject field in Icelandic', $comment_is->getSubject());
|
||||
$this->assertSame('1000000', $comment->field_integer->value);
|
||||
$this->assertSame('2000000', $comment_fr->field_integer->value);
|
||||
$this->assertSame('3000000', $comment_is->field_integer->value);
|
||||
|
||||
// Test that the French translation metadata is correctly migrated.
|
||||
$metadata_fr = $manager->getTranslationMetadata($comment_fr);
|
||||
$this->assertFalse($metadata_fr->isPublished());
|
||||
$this->assertSame('en', $metadata_fr->getSource());
|
||||
$this->assertSame('1', $metadata_fr->getAuthor()->uid->value);
|
||||
$this->assertSame('1531837764', $metadata_fr->getCreatedTime());
|
||||
$this->assertSame('1531837764', $metadata_fr->getChangedTime());
|
||||
$this->assertFalse($metadata_fr->isOutdated());
|
||||
|
||||
// Test that the Icelandic translation metadata is correctly migrated.
|
||||
$metadata_is = $manager->getTranslationMetadata($comment_is);
|
||||
$this->assertTrue($metadata_is->isPublished());
|
||||
$this->assertSame('en', $metadata_is->getSource());
|
||||
$this->assertSame('2', $metadata_is->getAuthor()->uid->value);
|
||||
$this->assertSame('1531838064', $metadata_is->getCreatedTime());
|
||||
$this->assertSame('1531838064', $metadata_is->getChangedTime());
|
||||
$this->assertTrue($metadata_is->isOutdated());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
@@ -66,10 +66,12 @@ class CommentSourceWithHighWaterTest extends MigrateSqlSourceTestBase {
|
||||
[
|
||||
'nid' => 2,
|
||||
'type' => 'story',
|
||||
'language' => 'en',
|
||||
],
|
||||
[
|
||||
'nid' => 3,
|
||||
'type' => 'page',
|
||||
'language' => 'fr',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -91,6 +93,7 @@ class CommentSourceWithHighWaterTest extends MigrateSqlSourceTestBase {
|
||||
'homepage' => '',
|
||||
'format' => 'testformat2',
|
||||
'type' => 'page',
|
||||
'language' => 'fr',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@@ -65,10 +65,12 @@ class CommentTest extends MigrateSqlSourceTestBase {
|
||||
[
|
||||
'nid' => 2,
|
||||
'type' => 'story',
|
||||
'language' => 'en',
|
||||
],
|
||||
[
|
||||
'nid' => 3,
|
||||
'type' => 'page',
|
||||
'language' => 'fr',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -90,6 +92,7 @@ class CommentTest extends MigrateSqlSourceTestBase {
|
||||
'homepage' => '',
|
||||
'format' => 'testformat1',
|
||||
'type' => 'story',
|
||||
'language' => 'en',
|
||||
],
|
||||
[
|
||||
'cid' => 2,
|
||||
@@ -107,6 +110,7 @@ class CommentTest extends MigrateSqlSourceTestBase {
|
||||
'homepage' => '',
|
||||
'format' => 'testformat2',
|
||||
'type' => 'page',
|
||||
'language' => 'fr',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
+281
@@ -0,0 +1,281 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\comment\Kernel\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D7 comment entity translation source plugin.
|
||||
*
|
||||
* @covers \Drupal\comment\Plugin\migrate\source\d7\CommentEntityTranslation
|
||||
* @group comment
|
||||
*/
|
||||
class CommentEntityTranslationTest 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' => 'en',
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['entity_translation'] = [
|
||||
[
|
||||
'entity_type' => 'comment',
|
||||
'entity_id' => 1,
|
||||
'revision_id' => 1,
|
||||
'language' => 'en',
|
||||
'source' => '',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'translate' => 0,
|
||||
'created' => '1421727536',
|
||||
'changed' => '1421727536',
|
||||
],
|
||||
[
|
||||
'entity_type' => 'comment',
|
||||
'entity_id' => 1,
|
||||
'revision_id' => 1,
|
||||
'language' => 'fr',
|
||||
'source' => 'en',
|
||||
'uid' => 1,
|
||||
'status' => 0,
|
||||
'translate' => 0,
|
||||
'created' => 1531343508,
|
||||
'changed' => 1531343508,
|
||||
],
|
||||
[
|
||||
'entity_type' => 'comment',
|
||||
'entity_id' => 1,
|
||||
'revision_id' => 1,
|
||||
'language' => 'es',
|
||||
'source' => 'en',
|
||||
'uid' => 2,
|
||||
'status' => 1,
|
||||
'translate' => 1,
|
||||
'created' => 1531343528,
|
||||
'changed' => 1531343528,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['field_config'] = [
|
||||
[
|
||||
'id' => 1,
|
||||
'field_name' => 'field_test',
|
||||
'type' => 'text',
|
||||
'module' => 'text',
|
||||
'active' => 1,
|
||||
'storage_type' => 'field_sql_storage',
|
||||
'storage_module' => 'field_sql_storage',
|
||||
'storage_active' => 1,
|
||||
'locked' => 1,
|
||||
'data' => 'a:0:{}',
|
||||
'cardinality' => 1,
|
||||
'translatable' => 1,
|
||||
'deleted' => 0,
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'field_name' => 'subject_field',
|
||||
'type' => 'text',
|
||||
'module' => 'text',
|
||||
'active' => 1,
|
||||
'storage_type' => 'field_sql_storage',
|
||||
'storage_module' => 'field_sql_storage',
|
||||
'storage_active' => 1,
|
||||
'locked' => 1,
|
||||
'data' => 'a:0:{}',
|
||||
'cardinality' => 1,
|
||||
'translatable' => 1,
|
||||
'deleted' => 0,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['field_config_instance'] = [
|
||||
[
|
||||
'id' => '1',
|
||||
'field_id' => '1',
|
||||
'field_name' => 'field_test',
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_test_content_type',
|
||||
'data' => 'a:0:{}',
|
||||
'deleted' => '0',
|
||||
],
|
||||
[
|
||||
'id' => '2',
|
||||
'field_id' => '2',
|
||||
'field_name' => 'subject_field',
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_test_content_type',
|
||||
'data' => 'a:0:{}',
|
||||
'deleted' => '0',
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['field_data_field_test'] = [
|
||||
[
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_test_content_type',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '1',
|
||||
'revision_id' => '1',
|
||||
'language' => 'en',
|
||||
'delta' => '0',
|
||||
'field_test_value' => 'This is an English comment',
|
||||
'field_test_format' => NULL,
|
||||
],
|
||||
[
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_test_content_type',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '1',
|
||||
'revision_id' => '1',
|
||||
'language' => 'fr',
|
||||
'delta' => '0',
|
||||
'field_test_value' => 'This is a French comment',
|
||||
'field_test_format' => NULL,
|
||||
],
|
||||
[
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_test_content_type',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '1',
|
||||
'revision_id' => '1',
|
||||
'language' => 'es',
|
||||
'delta' => '0',
|
||||
'field_test_value' => 'This is a Spanish comment',
|
||||
'field_test_format' => NULL,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['field_data_subject_field'] = [
|
||||
[
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_test_content_type',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '1',
|
||||
'revision_id' => '1',
|
||||
'language' => 'en',
|
||||
'delta' => '0',
|
||||
'subject_field_value' => 'Comment subject in English',
|
||||
'subject_field_format' => NULL,
|
||||
],
|
||||
[
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_test_content_type',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '1',
|
||||
'revision_id' => '1',
|
||||
'language' => 'fr',
|
||||
'delta' => '0',
|
||||
'subject_field_value' => 'Comment subject in French',
|
||||
'subject_field_format' => NULL,
|
||||
],
|
||||
[
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_test_content_type',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '1',
|
||||
'revision_id' => '1',
|
||||
'language' => 'es',
|
||||
'delta' => '0',
|
||||
'subject_field_value' => 'Comment subject in Spanish',
|
||||
'subject_field_format' => NULL,
|
||||
],
|
||||
];
|
||||
$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',
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'subject' => 'A comment',
|
||||
'entity_type' => 'comment',
|
||||
'entity_id' => '1',
|
||||
'revision_id' => '1',
|
||||
'language' => 'fr',
|
||||
'source' => 'en',
|
||||
'uid' => '1',
|
||||
'status' => '0',
|
||||
'translate' => '0',
|
||||
'created' => '1531343508',
|
||||
'changed' => '1531343508',
|
||||
'field_test' => [
|
||||
[
|
||||
'value' => 'This is a French comment',
|
||||
'format' => NULL,
|
||||
],
|
||||
],
|
||||
'subject_field' => [
|
||||
[
|
||||
'value' => 'Comment subject in French',
|
||||
'format' => NULL,
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'subject' => 'A comment',
|
||||
'entity_type' => 'comment',
|
||||
'entity_id' => '1',
|
||||
'revision_id' => '1',
|
||||
'language' => 'es',
|
||||
'source' => 'en',
|
||||
'uid' => '2',
|
||||
'status' => '1',
|
||||
'translate' => '1',
|
||||
'created' => '1531343528',
|
||||
'changed' => '1531343528',
|
||||
'field_test' => [
|
||||
[
|
||||
'value' => 'This is a Spanish comment',
|
||||
'format' => NULL,
|
||||
],
|
||||
],
|
||||
'subject_field' => [
|
||||
[
|
||||
'value' => 'Comment subject in Spanish',
|
||||
'format' => NULL,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user