Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -31,14 +31,14 @@ function comment_test_comment_links_alter(array &$links, CommentInterface &$enti
|
|||
return;
|
||||
}
|
||||
|
||||
$links['comment_test'] = array(
|
||||
$links['comment_test'] = [
|
||||
'#theme' => 'links__comment__comment_test',
|
||||
'#attributes' => array('class' => array('links', 'inline')),
|
||||
'#links' => array(
|
||||
'comment-report' => array(
|
||||
'#attributes' => ['class' => ['links', 'inline']],
|
||||
'#links' => [
|
||||
'comment-report' => [
|
||||
'title' => t('Report'),
|
||||
'url' => Url::fromRoute('comment_test.report', ['comment' => $entity->id()], ['query' => ['token' => \Drupal::getContainer()->get('csrf_token')->get("comment/{$entity->id()}/report")]]),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('entity_test', 'comment');
|
||||
public static $modules = ['entity_test', 'comment'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -48,11 +48,11 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase {
|
|||
// user does not have access to the 'administer comments' permission, to
|
||||
// ensure only published comments are visible to the end user.
|
||||
$current_user = $this->container->get('current_user');
|
||||
$current_user->setAccount($this->createUser(array(), array('access comments')));
|
||||
$current_user->setAccount($this->createUser([], ['access comments']));
|
||||
|
||||
// Install tables and config needed to render comments.
|
||||
$this->installSchema('comment', array('comment_entity_statistics'));
|
||||
$this->installConfig(array('system', 'filter', 'comment'));
|
||||
$this->installSchema('comment', ['comment_entity_statistics']);
|
||||
$this->installConfig(['system', 'filter', 'comment']);
|
||||
|
||||
// Comment rendering generates links, so build the router.
|
||||
$this->container->get('router.builder')->rebuild();
|
||||
|
@ -70,7 +70,7 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase {
|
|||
$renderer = $this->container->get('renderer');
|
||||
|
||||
// Create the entity that will be commented upon.
|
||||
$commented_entity = EntityTest::create(array('name' => $this->randomMachineName()));
|
||||
$commented_entity = EntityTest::create(['name' => $this->randomMachineName()]);
|
||||
$commented_entity->save();
|
||||
|
||||
// Verify cache tags on the rendered entity before it has comments.
|
||||
|
@ -94,19 +94,19 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase {
|
|||
// also exists in the {users} table.
|
||||
$user = $this->createUser();
|
||||
$user->save();
|
||||
$comment = Comment::create(array(
|
||||
$comment = Comment::create([
|
||||
'subject' => 'Llama',
|
||||
'comment_body' => array(
|
||||
'comment_body' => [
|
||||
'value' => 'Llamas are cool!',
|
||||
'format' => 'plain_text',
|
||||
),
|
||||
],
|
||||
'entity_id' => $commented_entity->id(),
|
||||
'entity_type' => 'entity_test',
|
||||
'field_name' => 'comment',
|
||||
'comment_type' => 'comment',
|
||||
'status' => CommentInterface::PUBLISHED,
|
||||
'uid' => $user->id(),
|
||||
));
|
||||
]);
|
||||
$comment->save();
|
||||
|
||||
// Load commented entity so comment_count gets computed.
|
||||
|
|
|
@ -29,30 +29,30 @@ class CommentFieldAccessTest extends EntityKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('comment', 'entity_test', 'user');
|
||||
public static $modules = ['comment', 'entity_test', 'user'];
|
||||
|
||||
/**
|
||||
* Fields that only users with administer comments permissions can change.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $administrativeFields = array(
|
||||
protected $administrativeFields = [
|
||||
'uid',
|
||||
'status',
|
||||
'created',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* These fields are automatically managed and can not be changed by any user.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $readOnlyFields = array(
|
||||
protected $readOnlyFields = [
|
||||
'changed',
|
||||
'hostname',
|
||||
'cid',
|
||||
'thread',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* These fields can be edited on create only.
|
||||
|
@ -73,19 +73,19 @@ class CommentFieldAccessTest extends EntityKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $contactFields = array(
|
||||
protected $contactFields = [
|
||||
'name',
|
||||
'mail',
|
||||
'homepage',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installConfig(array('user', 'comment'));
|
||||
$this->installSchema('comment', array('comment_entity_statistics'));
|
||||
$this->installConfig(['user', 'comment']);
|
||||
$this->installSchema('comment', ['comment_entity_statistics']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,21 +18,21 @@ class CommentStringIdEntitiesTest extends KernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array(
|
||||
public static $modules = [
|
||||
'comment',
|
||||
'user',
|
||||
'field',
|
||||
'field_ui',
|
||||
'entity_test',
|
||||
'text',
|
||||
);
|
||||
];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('comment');
|
||||
$this->installSchema('comment', array('comment_entity_statistics'));
|
||||
$this->installSchema('comment', ['comment_entity_statistics']);
|
||||
// Create the comment body field storage.
|
||||
$this->installConfig(array('field'));
|
||||
$this->installConfig(['field']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,21 +40,21 @@ class CommentStringIdEntitiesTest extends KernelTestBase {
|
|||
*/
|
||||
public function testCommentFieldNonStringId() {
|
||||
try {
|
||||
$bundle = CommentType::create(array(
|
||||
$bundle = CommentType::create([
|
||||
'id' => 'foo',
|
||||
'label' => 'foo',
|
||||
'description' => '',
|
||||
'target_entity_type_id' => 'entity_test_string_id',
|
||||
));
|
||||
]);
|
||||
$bundle->save();
|
||||
$field_storage = FieldStorageConfig::create(array(
|
||||
$field_storage = FieldStorageConfig::create([
|
||||
'field_name' => 'foo',
|
||||
'entity_type' => 'entity_test_string_id',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'comment_type' => 'entity_test_string_id',
|
||||
),
|
||||
],
|
||||
'type' => 'comment',
|
||||
));
|
||||
]);
|
||||
$field_storage->save();
|
||||
$this->fail('Did not throw an exception as expected.');
|
||||
}
|
||||
|
|
|
@ -19,14 +19,14 @@ class CommentValidationTest extends EntityKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('comment', 'node');
|
||||
public static $modules = ['comment', 'node'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('comment', array('comment_entity_statistics'));
|
||||
$this->installSchema('comment', ['comment_entity_statistics']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,54 +34,54 @@ class CommentValidationTest extends EntityKernelTestBase {
|
|||
*/
|
||||
public function testValidation() {
|
||||
// Add a user.
|
||||
$user = User::create(array('name' => 'test', 'status' => TRUE));
|
||||
$user = User::create(['name' => 'test', 'status' => TRUE]);
|
||||
$user->save();
|
||||
|
||||
// Add comment type.
|
||||
$this->entityManager->getStorage('comment_type')->create(array(
|
||||
$this->entityManager->getStorage('comment_type')->create([
|
||||
'id' => 'comment',
|
||||
'label' => 'comment',
|
||||
'target_entity_type_id' => 'node',
|
||||
))->save();
|
||||
])->save();
|
||||
|
||||
// Add comment field to content.
|
||||
$this->entityManager->getStorage('field_storage_config')->create(array(
|
||||
$this->entityManager->getStorage('field_storage_config')->create([
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'comment',
|
||||
'type' => 'comment',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'comment_type' => 'comment',
|
||||
)
|
||||
))->save();
|
||||
]
|
||||
])->save();
|
||||
|
||||
// Create a page node type.
|
||||
$this->entityManager->getStorage('node_type')->create(array(
|
||||
$this->entityManager->getStorage('node_type')->create([
|
||||
'type' => 'page',
|
||||
'name' => 'page',
|
||||
))->save();
|
||||
])->save();
|
||||
|
||||
// Add comment field to page content.
|
||||
/** @var \Drupal\field\FieldConfigInterface $field */
|
||||
$field = $this->entityManager->getStorage('field_config')->create(array(
|
||||
$field = $this->entityManager->getStorage('field_config')->create([
|
||||
'field_name' => 'comment',
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'page',
|
||||
'label' => 'Comment settings',
|
||||
));
|
||||
]);
|
||||
$field->save();
|
||||
|
||||
$node = $this->entityManager->getStorage('node')->create(array(
|
||||
$node = $this->entityManager->getStorage('node')->create([
|
||||
'type' => 'page',
|
||||
'title' => 'test',
|
||||
));
|
||||
]);
|
||||
$node->save();
|
||||
|
||||
$comment = $this->entityManager->getStorage('comment')->create(array(
|
||||
$comment = $this->entityManager->getStorage('comment')->create([
|
||||
'entity_id' => $node->id(),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'comment',
|
||||
'comment_body' => $this->randomMachineName(),
|
||||
));
|
||||
]);
|
||||
|
||||
$violations = $comment->validate();
|
||||
$this->assertEqual(count($violations), 0, 'No violations when validating a default comment.');
|
||||
|
@ -101,7 +101,7 @@ class CommentValidationTest extends EntityKernelTestBase {
|
|||
$violations = $comment->validate();
|
||||
$this->assertEqual(count($violations), 1, "Violation found on author name collision");
|
||||
$this->assertEqual($violations[0]->getPropertyPath(), "name");
|
||||
$this->assertEqual($violations[0]->getMessage(), t('The name you used (%name) belongs to a registered user.', array('%name' => 'test')));
|
||||
$this->assertEqual($violations[0]->getMessage(), t('The name you used (%name) belongs to a registered user.', ['%name' => 'test']));
|
||||
|
||||
// Make the name valid.
|
||||
$comment->set('name', 'valid unused name');
|
||||
|
@ -141,39 +141,39 @@ class CommentValidationTest extends EntityKernelTestBase {
|
|||
\Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]);
|
||||
$node = Node::load($node->id());
|
||||
// Create a new comment with the new field.
|
||||
$comment = $this->entityManager->getStorage('comment')->create(array(
|
||||
$comment = $this->entityManager->getStorage('comment')->create([
|
||||
'entity_id' => $node->id(),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'comment',
|
||||
'comment_body' => $this->randomMachineName(),
|
||||
'uid' => 0,
|
||||
'name' => '',
|
||||
));
|
||||
]);
|
||||
$violations = $comment->validate();
|
||||
$this->assertEqual(count($violations), 1, 'Violation found when name is required, but empty and UID is anonymous.');
|
||||
$this->assertEqual($violations[0]->getPropertyPath(), 'name');
|
||||
$this->assertEqual($violations[0]->getMessage(), t('You have to specify a valid author.'));
|
||||
|
||||
// Test creating a default comment with a given user id works.
|
||||
$comment = $this->entityManager->getStorage('comment')->create(array(
|
||||
$comment = $this->entityManager->getStorage('comment')->create([
|
||||
'entity_id' => $node->id(),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'comment',
|
||||
'comment_body' => $this->randomMachineName(),
|
||||
'uid' => $user->id(),
|
||||
));
|
||||
]);
|
||||
$violations = $comment->validate();
|
||||
$this->assertEqual(count($violations), 0, 'No violations when validating a default comment with an author.');
|
||||
|
||||
// Test specifying a wrong author name does not work.
|
||||
$comment = $this->entityManager->getStorage('comment')->create(array(
|
||||
$comment = $this->entityManager->getStorage('comment')->create([
|
||||
'entity_id' => $node->id(),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'comment',
|
||||
'comment_body' => $this->randomMachineName(),
|
||||
'uid' => $user->id(),
|
||||
'name' => 'not-test',
|
||||
));
|
||||
]);
|
||||
$violations = $comment->validate();
|
||||
$this->assertEqual(count($violations), 1, 'Violation found when author name and comment author do not match.');
|
||||
$this->assertEqual($violations[0]->getPropertyPath(), 'name');
|
||||
|
@ -195,7 +195,7 @@ class CommentValidationTest extends EntityKernelTestBase {
|
|||
$this->assertEqual(count($violations), 1, "Violation found when $field_name is too long.");
|
||||
$this->assertEqual($violations[0]->getPropertyPath(), "$field_name.0.value");
|
||||
$field_label = $comment->get($field_name)->getFieldDefinition()->getLabel();
|
||||
$this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', array('%name' => $field_label, '@max' => $length)));
|
||||
$this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', ['%name' => $field_label, '@max' => $length]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,11 +33,11 @@ class MigrateCommentStubTest extends MigrateDrupalTestBase {
|
|||
$storage = \Drupal::entityManager()->getStorage('user');
|
||||
// Insert a row for the anonymous user.
|
||||
$storage
|
||||
->create(array(
|
||||
->create([
|
||||
'uid' => 0,
|
||||
'status' => 0,
|
||||
'name' => '',
|
||||
))
|
||||
])
|
||||
->save();
|
||||
// Need at least one node type and comment type present.
|
||||
NodeType::create([
|
||||
|
|
|
@ -61,14 +61,17 @@ class MigrateCommentTest extends MigrateDrupal6TestBase {
|
|||
$this->assertIdentical('node', $comment->getCommentedEntityTypeId());
|
||||
$this->assertIdentical('en', $comment->language()->getId());
|
||||
$this->assertIdentical('comment_no_subject', $comment->getTypeId());
|
||||
$this->assertEquals('203.0.113.1', $comment->getHostname());
|
||||
|
||||
$comment = $comment_storage->load(2);
|
||||
$this->assertIdentical('The response to the second comment.', $comment->subject->value);
|
||||
$this->assertIdentical('3', $comment->pid->target_id);
|
||||
$this->assertEquals('203.0.113.2', $comment->getHostname());
|
||||
|
||||
$comment = $comment_storage->load(3);
|
||||
$this->assertIdentical('The second comment.', $comment->subject->value);
|
||||
$this->assertIdentical(NULL, $comment->pid->target_id);
|
||||
$this->assertEquals('203.0.113.3', $comment->getHostname());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,11 +34,11 @@ class MigrateCommentTest extends MigrateDrupal7TestBase {
|
|||
$this->executeMigration('d7_node_type');
|
||||
// We only need the test_content_type node migration to run for real, so
|
||||
// mock all the others.
|
||||
$this->prepareMigrations(array(
|
||||
'd7_node' => array(
|
||||
array(array(0), array(0)),
|
||||
),
|
||||
));
|
||||
$this->prepareMigrations([
|
||||
'd7_node' => [
|
||||
[[0], [0]],
|
||||
],
|
||||
]);
|
||||
$this->executeMigrations([
|
||||
'd7_node',
|
||||
'd7_comment_type',
|
||||
|
@ -61,6 +61,7 @@ class MigrateCommentTest extends MigrateDrupal7TestBase {
|
|||
$this->assertIdentical('admin@local.host', $comment->getAuthorEmail());
|
||||
$this->assertIdentical('This is a comment', $comment->comment_body->value);
|
||||
$this->assertIdentical('filtered_html', $comment->comment_body->format);
|
||||
$this->assertEquals('2001:db8:ffff:ffff:ffff:ffff:ffff:ffff', $comment->getHostname());
|
||||
|
||||
$node = $comment->getCommentedEntity();
|
||||
$this->assertTrue($node instanceof NodeInterface);
|
||||
|
|
|
@ -43,11 +43,11 @@ class CommentUserNameTest extends ViewsKernelTestBase {
|
|||
$storage = \Drupal::entityManager()->getStorage('user');
|
||||
// Insert a row for the anonymous user.
|
||||
$storage
|
||||
->create(array(
|
||||
->create([
|
||||
'uid' => 0,
|
||||
'name' => '',
|
||||
'status' => 0,
|
||||
))
|
||||
])
|
||||
->save();
|
||||
|
||||
$admin_role = Role::create([
|
||||
|
|
|
@ -75,9 +75,9 @@ class CommentLinkBuilderTest extends UnitTestCase {
|
|||
$this->commentManager->expects($this->any())
|
||||
->method('getFields')
|
||||
->with('node')
|
||||
->willReturn(array(
|
||||
'comment' => array(),
|
||||
));
|
||||
->willReturn([
|
||||
'comment' => [],
|
||||
]);
|
||||
$this->commentManager->expects($this->any())
|
||||
->method('forbiddenMessage')
|
||||
->willReturn("Can't let you do that Dave.");
|
||||
|
@ -116,10 +116,10 @@ class CommentLinkBuilderTest extends UnitTestCase {
|
|||
->willReturn($history_exists);
|
||||
$this->currentUser->expects($this->any())
|
||||
->method('hasPermission')
|
||||
->willReturnMap(array(
|
||||
array('access comments', $has_access_comments),
|
||||
array('post comments', $has_post_comments),
|
||||
));
|
||||
->willReturnMap([
|
||||
['access comments', $has_access_comments],
|
||||
['post comments', $has_post_comments],
|
||||
]);
|
||||
$this->currentUser->expects($this->any())
|
||||
->method('isAuthenticated')
|
||||
->willReturn(!$is_anonymous);
|
||||
|
@ -155,57 +155,57 @@ class CommentLinkBuilderTest extends UnitTestCase {
|
|||
* Data provider for ::testCommentLinkBuilder.
|
||||
*/
|
||||
public function getLinkCombinations() {
|
||||
$cases = array();
|
||||
$cases = [];
|
||||
// No links should be created if the entity doesn't have the field.
|
||||
$cases[] = array(
|
||||
$cases[] = [
|
||||
$this->getMockNode(FALSE, CommentItemInterface::OPEN, CommentItemInterface::FORM_BELOW, 1),
|
||||
array('view_mode' => 'teaser'),
|
||||
['view_mode' => 'teaser'],
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE,
|
||||
array(),
|
||||
);
|
||||
foreach (array('search_result', 'search_index', 'print') as $view_mode) {
|
||||
[],
|
||||
];
|
||||
foreach (['search_result', 'search_index', 'print'] as $view_mode) {
|
||||
// Nothing should be output in these view modes.
|
||||
$cases[] = array(
|
||||
$cases[] = [
|
||||
$this->getMockNode(TRUE, CommentItemInterface::OPEN, CommentItemInterface::FORM_BELOW, 1),
|
||||
array('view_mode' => $view_mode),
|
||||
['view_mode' => $view_mode],
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE,
|
||||
array(),
|
||||
);
|
||||
[],
|
||||
];
|
||||
}
|
||||
// All other combinations.
|
||||
$combinations = array(
|
||||
'is_anonymous' => array(FALSE, TRUE),
|
||||
'comment_count' => array(0, 1),
|
||||
'has_access_comments' => array(0, 1),
|
||||
'history_exists' => array(FALSE, TRUE),
|
||||
'has_post_comments' => array(0, 1),
|
||||
'form_location' => array(CommentItemInterface::FORM_BELOW, CommentItemInterface::FORM_SEPARATE_PAGE),
|
||||
'comments' => array(
|
||||
$combinations = [
|
||||
'is_anonymous' => [FALSE, TRUE],
|
||||
'comment_count' => [0, 1],
|
||||
'has_access_comments' => [0, 1],
|
||||
'history_exists' => [FALSE, TRUE],
|
||||
'has_post_comments' => [0, 1],
|
||||
'form_location' => [CommentItemInterface::FORM_BELOW, CommentItemInterface::FORM_SEPARATE_PAGE],
|
||||
'comments' => [
|
||||
CommentItemInterface::OPEN,
|
||||
CommentItemInterface::CLOSED,
|
||||
CommentItemInterface::HIDDEN,
|
||||
),
|
||||
'view_mode' => array(
|
||||
],
|
||||
'view_mode' => [
|
||||
'teaser', 'rss', 'full',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$permutations = TestBase::generatePermutations($combinations);
|
||||
foreach ($permutations as $combination) {
|
||||
$case = array(
|
||||
$case = [
|
||||
$this->getMockNode(TRUE, $combination['comments'], $combination['form_location'], $combination['comment_count']),
|
||||
array('view_mode' => $combination['view_mode']),
|
||||
['view_mode' => $combination['view_mode']],
|
||||
$combination['has_access_comments'],
|
||||
$combination['history_exists'],
|
||||
$combination['has_post_comments'],
|
||||
$combination['is_anonymous'],
|
||||
);
|
||||
$expected = array();
|
||||
];
|
||||
$expected = [];
|
||||
// When comments are enabled in teaser mode, and comments exist, and the
|
||||
// user has access - we can output the comment count.
|
||||
if ($combination['comments'] && $combination['view_mode'] == 'teaser' && $combination['comment_count'] && $combination['has_access_comments']) {
|
||||
|
@ -225,7 +225,7 @@ class CommentLinkBuilderTest extends UnitTestCase {
|
|||
// comments exist or the form is on a separate page.
|
||||
if ($combination['view_mode'] == 'teaser' || ($combination['has_access_comments'] && $combination['comment_count']) || $combination['form_location'] == CommentItemInterface::FORM_SEPARATE_PAGE) {
|
||||
// There should be a add comment link.
|
||||
$expected['comment-add'] = array('title' => 'Add new comment');
|
||||
$expected['comment-add'] = ['title' => 'Add new comment'];
|
||||
if ($combination['form_location'] == CommentItemInterface::FORM_BELOW) {
|
||||
// On the same page.
|
||||
$expected['comment-add']['url'] = Url::fromRoute('node.view');
|
||||
|
@ -274,11 +274,11 @@ class CommentLinkBuilderTest extends UnitTestCase {
|
|||
if (empty($this->timestamp)) {
|
||||
$this->timestamp = time();
|
||||
}
|
||||
$field_item = (object) array(
|
||||
$field_item = (object) [
|
||||
'status' => $comment_status,
|
||||
'comment_count' => $comment_count,
|
||||
'last_comment_timestamp' => $this->timestamp,
|
||||
);
|
||||
];
|
||||
$node->expects($this->any())
|
||||
->method('get')
|
||||
->with('comment')
|
||||
|
@ -312,7 +312,7 @@ class CommentLinkBuilderTest extends UnitTestCase {
|
|||
->willReturn($url);
|
||||
$node->expects($this->any())
|
||||
->method('url')
|
||||
->willReturn(array('route_name' => 'node.view'));
|
||||
->willReturn(['route_name' => 'node.view']);
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Drupal\Tests\comment\Unit;
|
||||
|
||||
use Drupal\comment\CommentManager;
|
||||
use Drupal\Core\Entity\FieldableEntityInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
|
@ -23,21 +24,21 @@ class CommentManagerTest extends UnitTestCase {
|
|||
->method('getClass')
|
||||
->will($this->returnValue('Node'));
|
||||
$entity_type->expects($this->any())
|
||||
->method('isSubclassOf')
|
||||
->with('\Drupal\Core\Entity\FieldableEntityInterface')
|
||||
->method('entityClassImplements')
|
||||
->with(FieldableEntityInterface::class)
|
||||
->will($this->returnValue(TRUE));
|
||||
|
||||
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
|
||||
|
||||
$entity_manager->expects($this->once())
|
||||
->method('getFieldMapByFieldType')
|
||||
->will($this->returnValue(array(
|
||||
'node' => array(
|
||||
'field_foobar' => array(
|
||||
->will($this->returnValue([
|
||||
'node' => [
|
||||
'field_foobar' => [
|
||||
'type' => 'comment',
|
||||
),
|
||||
),
|
||||
)));
|
||||
],
|
||||
],
|
||||
]));
|
||||
|
||||
$entity_manager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
|
@ -45,7 +46,6 @@ class CommentManagerTest extends UnitTestCase {
|
|||
|
||||
$comment_manager = new CommentManager(
|
||||
$entity_manager,
|
||||
$this->getMockBuilder('Drupal\Core\Entity\Query\QueryFactory')->disableOriginalConstructor()->getMock(),
|
||||
$this->getMock('Drupal\Core\Config\ConfigFactoryInterface'),
|
||||
$this->getMock('Drupal\Core\StringTranslation\TranslationInterface'),
|
||||
$this->getMock('Drupal\Core\Routing\UrlGeneratorInterface'),
|
||||
|
|
|
@ -56,7 +56,7 @@ class CommentStatisticsUnitTest extends UnitTestCase {
|
|||
|
||||
$this->statement->expects($this->any())
|
||||
->method('fetchObject')
|
||||
->will($this->returnCallback(array($this, 'fetchObjectCallback')));
|
||||
->will($this->returnCallback([$this, 'fetchObjectCallback']));
|
||||
|
||||
$this->select = $this->getMockBuilder('Drupal\Core\Database\Query\Select')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -95,8 +95,8 @@ class CommentStatisticsUnitTest extends UnitTestCase {
|
|||
*/
|
||||
public function testRead() {
|
||||
$this->calls_to_fetch = 0;
|
||||
$results = $this->commentStatistics->read(array('1' => 'boo', '2' => 'foo'), 'snafoos');
|
||||
$this->assertEquals($results, array('something', 'something-else'));
|
||||
$results = $this->commentStatistics->read(['1' => 'boo', '2' => 'foo'], 'snafoos');
|
||||
$this->assertEquals($results, ['something', 'something-else']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,7 +26,7 @@ class CommentLockTest extends UnitTestCase {
|
|||
$request_stack = new RequestStack();
|
||||
$request_stack->push(Request::create('/'));
|
||||
$container->set('request_stack', $request_stack);
|
||||
$container->setParameter('cache_bins', array('cache.test' => 'test'));
|
||||
$container->setParameter('cache_bins', ['cache.test' => 'test']);
|
||||
$lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface');
|
||||
$cid = 2;
|
||||
$lock_name = "comment:$cid:.00/";
|
||||
|
@ -84,7 +84,7 @@ class CommentLockTest extends UnitTestCase {
|
|||
$comment->expects($this->at(1))
|
||||
->method('get')
|
||||
->with('status')
|
||||
->will($this->returnValue((object) array('value' => NULL)));
|
||||
->will($this->returnValue((object) ['value' => NULL]));
|
||||
$storage = $this->getMock('Drupal\comment\CommentStorageInterface');
|
||||
|
||||
// preSave() should acquire the lock. (This is what's really being tested.)
|
||||
|
|
|
@ -14,20 +14,20 @@ abstract class CommentTestBase extends MigrateSqlSourceTestCase {
|
|||
const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d6\Comment';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
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' => array(
|
||||
'source' => [
|
||||
'plugin' => 'd6_comment',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// We need to set up the database contents; it's easier to do that below.
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'cid' => 1,
|
||||
'pid' => 0,
|
||||
'nid' => 2,
|
||||
|
@ -43,8 +43,8 @@ abstract class CommentTestBase extends MigrateSqlSourceTestCase {
|
|||
'homepage' => '',
|
||||
'format' => 'testformat1',
|
||||
'type' => 'story',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'cid' => 2,
|
||||
'pid' => 1,
|
||||
'nid' => 3,
|
||||
|
@ -60,8 +60,8 @@ abstract class CommentTestBase extends MigrateSqlSourceTestCase {
|
|||
'homepage' => '',
|
||||
'format' => 'testformat2',
|
||||
'type' => 'page',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -72,8 +72,8 @@ abstract class CommentTestBase extends MigrateSqlSourceTestCase {
|
|||
$this->databaseContents['comments'][$k]['status'] = 1 - $this->databaseContents['comments'][$k]['status'];
|
||||
}
|
||||
// Add node table data.
|
||||
$this->databaseContents['node'][] = array('nid' => 2, 'type' => 'story');
|
||||
$this->databaseContents['node'][] = array('nid' => 3, 'type' => 'page');
|
||||
$this->databaseContents['node'][] = ['nid' => 2, 'type' => 'story'];
|
||||
$this->databaseContents['node'][] = ['nid' => 3, 'type' => 'page'];
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,46 +13,46 @@ class CommentVariablePerCommentTypeTest extends MigrateSqlSourceTestCase {
|
|||
|
||||
const PLUGIN_CLASS = CommentVariablePerCommentType::class;
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'source' => [
|
||||
'plugin' => 'd6_comment_variable_per_comment_type',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = array(
|
||||
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.
|
||||
array(
|
||||
[
|
||||
'comment_type' => 'comment',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'comment_type' => 'comment_no_subject',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['node_type'] = array(
|
||||
array(
|
||||
$this->databaseContents['node_type'] = [
|
||||
[
|
||||
'type' => 'page',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'type' => 'story',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['variable'] = array(
|
||||
array(
|
||||
],
|
||||
];
|
||||
$this->databaseContents['variable'] = [
|
||||
[
|
||||
'name' => 'comment_subject_field_page',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'comment_subject_field_story',
|
||||
'value' => serialize(0),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,15 +13,15 @@ class CommentVariableTest extends MigrateSqlSourceTestCase {
|
|||
|
||||
const PLUGIN_CLASS = CommentVariable::class;
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'source' => [
|
||||
'plugin' => 'd6_comment_variable',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'comment' => '1',
|
||||
'comment_default_mode' => '1',
|
||||
'comment_default_order' => '1',
|
||||
|
@ -33,56 +33,56 @@ class CommentVariableTest extends MigrateSqlSourceTestCase {
|
|||
'comment_form_location' => '1',
|
||||
'node_type' => 'page',
|
||||
'comment_type' => 'comment',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['node_type'] = array(
|
||||
array(
|
||||
$this->databaseContents['node_type'] = [
|
||||
[
|
||||
'type' => 'page',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['variable'] = array(
|
||||
array(
|
||||
],
|
||||
];
|
||||
$this->databaseContents['variable'] = [
|
||||
[
|
||||
'name' => 'comment_page',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'comment_default_mode_page',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'comment_default_order_page',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'comment_default_per_page_page',
|
||||
'value' => serialize(50),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'comment_controls_page',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'comment_anonymous_page',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'comment_subject_field_page',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'comment_preview_page',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'comment_form_location_page',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,15 +13,15 @@ class CommentTest extends MigrateSqlSourceTestCase {
|
|||
|
||||
const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d7\Comment';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'source' => [
|
||||
'plugin' => 'd7_comment',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'cid' => '1',
|
||||
'pid' => '0',
|
||||
'nid' => '1',
|
||||
|
@ -36,14 +36,14 @@ class CommentTest extends MigrateSqlSourceTestCase {
|
|||
'mail' => '',
|
||||
'homepage' => '',
|
||||
'language' => 'und',
|
||||
'comment_body' => array(
|
||||
array(
|
||||
'comment_body' => [
|
||||
[
|
||||
'value' => 'This is a comment',
|
||||
'format' => 'filtered_html',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -52,8 +52,8 @@ class CommentTest extends MigrateSqlSourceTestCase {
|
|||
$this->databaseContents['comment'] = $this->expectedResults;
|
||||
unset($this->databaseContents['comment'][0]['comment_body']);
|
||||
|
||||
$this->databaseContents['node'] = array(
|
||||
array(
|
||||
$this->databaseContents['node'] = [
|
||||
[
|
||||
'nid' => '1',
|
||||
'vid' => '1',
|
||||
'type' => 'test_content_type',
|
||||
|
@ -68,10 +68,10 @@ class CommentTest extends MigrateSqlSourceTestCase {
|
|||
'sticky' => '0',
|
||||
'tnid' => '0',
|
||||
'translate' => '0',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['field_config_instance'] = array(
|
||||
array(
|
||||
],
|
||||
];
|
||||
$this->databaseContents['field_config_instance'] = [
|
||||
[
|
||||
'id' => '14',
|
||||
'field_id' => '1',
|
||||
'field_name' => 'comment_body',
|
||||
|
@ -79,10 +79,10 @@ class CommentTest extends MigrateSqlSourceTestCase {
|
|||
'bundle' => 'comment_node_test_content_type',
|
||||
'data' => 'a:0:{}',
|
||||
'deleted' => '0',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['field_data_comment_body'] = array(
|
||||
array(
|
||||
],
|
||||
];
|
||||
$this->databaseContents['field_data_comment_body'] = [
|
||||
[
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_test_content_type',
|
||||
'deleted' => '0',
|
||||
|
@ -92,8 +92,8 @@ class CommentTest extends MigrateSqlSourceTestCase {
|
|||
'delta' => '0',
|
||||
'comment_body_value' => 'This is a comment',
|
||||
'comment_body_format' => 'filtered_html',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,15 +13,15 @@ class CommentTypeTest extends MigrateSqlSourceTestCase {
|
|||
|
||||
const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d7\CommentType';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'source' => [
|
||||
'plugin' => 'd7_comment_type',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'bundle' => 'comment_node_article',
|
||||
'node_type' => 'article',
|
||||
'default_mode' => '1',
|
||||
|
@ -31,15 +31,15 @@ class CommentTypeTest extends MigrateSqlSourceTestCase {
|
|||
'preview' => '0',
|
||||
'subject' => '1',
|
||||
'label' => 'Article comment',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['node_type'] = array(
|
||||
array(
|
||||
$this->databaseContents['node_type'] = [
|
||||
[
|
||||
'type' => 'article',
|
||||
'name' => 'Article',
|
||||
'base' => 'node_content',
|
||||
|
@ -53,10 +53,10 @@ class CommentTypeTest extends MigrateSqlSourceTestCase {
|
|||
'locked' => '0',
|
||||
'disabled' => '0',
|
||||
'orig_type' => 'article',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['field_config_instance'] = array(
|
||||
array(
|
||||
],
|
||||
];
|
||||
$this->databaseContents['field_config_instance'] = [
|
||||
[
|
||||
'id' => '14',
|
||||
'field_id' => '1',
|
||||
'field_name' => 'comment_body',
|
||||
|
@ -64,34 +64,34 @@ class CommentTypeTest extends MigrateSqlSourceTestCase {
|
|||
'bundle' => 'comment_node_article',
|
||||
'data' => 'a:0:{}',
|
||||
'deleted' => '0',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['variable'] = array(
|
||||
array(
|
||||
],
|
||||
];
|
||||
$this->databaseContents['variable'] = [
|
||||
[
|
||||
'name' => 'comment_default_mode_article',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'comment_per_page_article',
|
||||
'value' => serialize(50),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'comment_anonymous_article',
|
||||
'value' => serialize(0),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'comment_form_location_article',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'comment_preview_article',
|
||||
'value' => serialize(0),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'comment_subject_article',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue