Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0
This commit is contained in:
parent
2f563ab520
commit
f1c8716f57
1732 changed files with 52334 additions and 11780 deletions
|
@ -120,7 +120,7 @@ display:
|
|||
entity_field: subject
|
||||
filters:
|
||||
status:
|
||||
value: true
|
||||
value: '1'
|
||||
table: comment_field_data
|
||||
field: status
|
||||
id: status
|
||||
|
@ -131,7 +131,7 @@ display:
|
|||
entity_type: comment
|
||||
entity_field: status
|
||||
status_node:
|
||||
value: true
|
||||
value: '1'
|
||||
table: node_field_data
|
||||
field: status
|
||||
relationship: node
|
||||
|
|
|
@ -112,7 +112,9 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase {
|
|||
// Load commented entity so comment_count gets computed.
|
||||
// @todo Remove the $reset = TRUE parameter after
|
||||
// https://www.drupal.org/node/597236 lands. It's a temporary work-around.
|
||||
$commented_entity = entity_load('entity_test', $commented_entity->id(), TRUE);
|
||||
$storage = $this->container->get('entity_type.manager')->getStorage('entity_test');
|
||||
$storage->resetCache([$commented_entity->id()]);
|
||||
$commented_entity = $storage->load($commented_entity->id());
|
||||
|
||||
// Verify cache tags on the rendered entity when it has comments.
|
||||
$build = \Drupal::entityManager()
|
||||
|
|
138
core/modules/comment/tests/src/Kernel/CommentIntegrationTest.php
Normal file
138
core/modules/comment/tests/src/Kernel/CommentIntegrationTest.php
Normal file
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\comment\Kernel;
|
||||
|
||||
use Drupal\comment\Entity\CommentType;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\Core\Entity\Entity\EntityViewMode;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests integration of comment with other components.
|
||||
*
|
||||
* @group comment
|
||||
*/
|
||||
class CommentIntegrationTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['comment', 'field', 'entity_test', 'user', 'system', 'dblog'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('entity_test');
|
||||
$this->installEntitySchema('user');
|
||||
$this->installEntitySchema('comment');
|
||||
$this->installSchema('dblog', ['watchdog']);
|
||||
|
||||
// Create a new 'comment' comment-type.
|
||||
CommentType::create([
|
||||
'id' => 'comment',
|
||||
'label' => $this->randomString(),
|
||||
])->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests view mode setting integration.
|
||||
*
|
||||
* @see comment_entity_view_display_presave()
|
||||
* @see CommentDefaultFormatter::calculateDependencies()
|
||||
*/
|
||||
public function testViewMode() {
|
||||
$mode = Unicode::strtolower($this->randomMachineName());
|
||||
// Create a new comment view mode and a view display entity.
|
||||
EntityViewMode::create([
|
||||
'id' => "comment.$mode",
|
||||
'targetEntityType' => 'comment',
|
||||
'settings' => ['comment_type' => 'comment'],
|
||||
])->save();
|
||||
EntityViewDisplay::create([
|
||||
'targetEntityType' => 'comment',
|
||||
'bundle' => 'comment',
|
||||
'mode' => $mode,
|
||||
])->setStatus(TRUE)->save();
|
||||
|
||||
// Create a comment field attached to a host 'entity_test' entity.
|
||||
FieldStorageConfig::create([
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'comment',
|
||||
'field_name' => $field_name = Unicode::strtolower($this->randomMachineName()),
|
||||
'settings' => [
|
||||
'comment_type' => 'comment',
|
||||
],
|
||||
])->save();
|
||||
FieldConfig::create([
|
||||
'entity_type' => 'entity_test',
|
||||
'bundle' => 'entity_test',
|
||||
'field_name' => $field_name,
|
||||
])->save();
|
||||
|
||||
$component = [
|
||||
'type' => 'comment_default',
|
||||
'settings' => ['view_mode' => $mode, 'pager_id' => 0],
|
||||
];
|
||||
// Create a new 'entity_test' view display on host entity that uses the
|
||||
// custom comment display in field formatter to show the field.
|
||||
EntityViewDisplay::create([
|
||||
'targetEntityType' => 'entity_test',
|
||||
'bundle' => 'entity_test',
|
||||
'mode' => 'default',
|
||||
])->setComponent($field_name, $component)->setStatus(TRUE)->save();
|
||||
|
||||
$host_display_id = 'entity_test.entity_test.default';
|
||||
$comment_display_id = "comment.comment.$mode";
|
||||
|
||||
// Disable the "comment.comment.$mode" display.
|
||||
EntityViewDisplay::load($comment_display_id)->setStatus(FALSE)->save();
|
||||
|
||||
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $host_display */
|
||||
$host_display = EntityViewDisplay::load($host_display_id);
|
||||
|
||||
// Check that the field formatter has been disabled on host view display.
|
||||
$this->assertNull($host_display->getComponent($field_name));
|
||||
$this->assertTrue($host_display->get('hidden')[$field_name]);
|
||||
|
||||
// Check that the proper warning has been logged.
|
||||
$arguments = [
|
||||
'@id' => $host_display_id,
|
||||
'@name' => $field_name,
|
||||
'@display' => EntityViewMode::load("comment.$mode")->label(),
|
||||
'@mode' => $mode,
|
||||
];
|
||||
$logged = (bool) Database::getConnection()->select('watchdog')
|
||||
->fields('watchdog', ['wid'])
|
||||
->condition('type', 'system')
|
||||
->condition('message', "View display '@id': Comment field formatter '@name' was disabled because it is using the comment view display '@display' (@mode) that was just disabled.")
|
||||
->condition('variables', serialize($arguments))
|
||||
->execute()
|
||||
->fetchField();
|
||||
$this->assertTrue($logged);
|
||||
|
||||
// Re-enable the comment view display.
|
||||
EntityViewDisplay::load($comment_display_id)->setStatus(TRUE)->save();
|
||||
// Re-enable the comment field formatter on host entity view display.
|
||||
EntityViewDisplay::load($host_display_id)->setComponent($field_name, $component)->save();
|
||||
|
||||
// Delete the "comment.$mode" view mode.
|
||||
EntityViewMode::load("comment.$mode")->delete();
|
||||
|
||||
// Check that the comment view display entity has been deleted too.
|
||||
$this->assertNull(EntityViewDisplay::load($comment_display_id));
|
||||
|
||||
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */
|
||||
$host_display = EntityViewDisplay::load($host_display_id);
|
||||
|
||||
// Check that the field formatter has been disabled on host view display.
|
||||
$this->assertNull($host_display->getComponent($field_name));
|
||||
$this->assertTrue($host_display->get('hidden')[$field_name]);
|
||||
}
|
||||
|
||||
}
|
|
@ -43,7 +43,9 @@ class CommentItemTest extends FieldKernelTestBase {
|
|||
|
||||
// Verify entity has been created properly.
|
||||
$id = $entity->id();
|
||||
$entity = entity_load('entity_test', $id, TRUE);
|
||||
$storage = $this->container->get('entity_type.manager')->getStorage('entity_test');
|
||||
$storage->resetCache([$id]);
|
||||
$entity = $storage->load($id);
|
||||
$this->assertTrue($entity->comment instanceof FieldItemListInterface, 'Field implements interface.');
|
||||
$this->assertTrue($entity->comment[0] instanceof CommentItemInterface, 'Field item implements interface.');
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\comment\Unit {
|
||||
namespace Drupal\Tests\comment\Unit;
|
||||
|
||||
use Drupal\comment\CommentLinkBuilder;
|
||||
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
|
||||
|
@ -319,12 +319,10 @@ class CommentLinkBuilderTest extends UnitTestCase {
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
namespace Drupal\comment;
|
||||
|
||||
namespace {
|
||||
if (!function_exists('history_read')) {
|
||||
function history_read() {
|
||||
return 0;
|
||||
}
|
||||
if (!function_exists('history_read')) {
|
||||
function history_read() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,13 +111,12 @@ class CommentStatisticsUnitTest extends UnitTestCase {
|
|||
switch ($this->calls_to_fetch) {
|
||||
case 1:
|
||||
return 'something';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
return 'something-else';
|
||||
break;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class CommentSourceWithHighWaterTest extends CommentTestBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->migrationConfiguration['highWaterProperty']['field'] = 'timestamp';
|
||||
$this->migrationConfiguration['source']['high_water_property']['name'] = 'timestamp';
|
||||
array_shift($this->expectedResults);
|
||||
parent::setUp();
|
||||
}
|
||||
|
|
Reference in a new issue