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
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
|
||||
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
||||
/**
|
||||
|
@ -134,3 +136,46 @@ function comment_update_8001() {
|
|||
function comment_update_8002() {
|
||||
// Empty update to cause a cache flush.
|
||||
}
|
||||
|
||||
/**
|
||||
* @addtogroup updates-8.2.x
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add the 'view_mode' setting to displays having 'comment_default' formatter.
|
||||
*/
|
||||
function comment_update_8200() {
|
||||
$config_factory = \Drupal::configFactory();
|
||||
$displays = [];
|
||||
// Iterate on all entity view displays.
|
||||
foreach ($config_factory->listAll('core.entity_view_display.') as $name) {
|
||||
$changed = FALSE;
|
||||
$display = $config_factory->getEditable($name);
|
||||
$components = $display->get('content') ?: [];
|
||||
foreach ($components as $field_name => $component) {
|
||||
if (isset($component['type']) && ($component['type'] === 'comment_default')) {
|
||||
if (empty($display->get("content.{$field_name}.settings.view_mode"))) {
|
||||
$display->set("content.{$field_name}.settings.view_mode", 'default');
|
||||
$displays[] = $display->get('id');
|
||||
$changed = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($changed) {
|
||||
$display->save(TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if ($displays) {
|
||||
return new PluralTranslatableMarkup(count($displays), '1 entity display updated: @displays.', '@count entity displays updated: @displays.', ['@displays' => implode(', ', $displays)]);
|
||||
}
|
||||
else {
|
||||
return new TranslatableMarkup('No entity view display updated.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup updates-8.2.x".
|
||||
*/
|
||||
|
|
|
@ -14,6 +14,7 @@ use Drupal\comment\CommentInterface;
|
|||
use Drupal\comment\Entity\CommentType;
|
||||
use Drupal\Core\Entity\FieldableEntityInterface;
|
||||
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
|
||||
use Drupal\Core\Entity\Entity\EntityViewMode;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
|
@ -656,7 +657,7 @@ function template_preprocess_comment(&$variables) {
|
|||
$variables['permalink'] = \Drupal::l(t('Permalink'), new Url('<front>'));
|
||||
}
|
||||
else {
|
||||
$uri = $comment->urlInfo();
|
||||
$uri = $comment->permalink();
|
||||
$attributes = $uri->getOption('attributes') ?: array();
|
||||
$attributes += array('class' => array('permalink'), 'rel' => 'bookmark');
|
||||
$uri->setOption('attributes', $attributes);
|
||||
|
@ -756,3 +757,43 @@ function comment_preprocess_field(&$variables) {
|
|||
function comment_ranking() {
|
||||
return \Drupal::service('comment.statistics')->getRankingInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_ENTITY_TYPE_presave() for entity_view_display entities.
|
||||
*/
|
||||
function comment_entity_view_display_presave(EntityViewDisplayInterface $display) {
|
||||
// Act only on comment view displays being disabled.
|
||||
if ($display->isNew() || $display->getTargetEntityTypeId() !== 'comment' || $display->status()) {
|
||||
return;
|
||||
}
|
||||
$storage = \Drupal::entityTypeManager()->getStorage('entity_view_display');
|
||||
if (!$storage->loadUnchanged($display->getOriginalId())->status()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable the comment field formatter when the used view display is disabled.
|
||||
foreach ($storage->loadMultiple() as $id => $view_display) {
|
||||
$changed = FALSE;
|
||||
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_display */
|
||||
foreach ($view_display->getComponents() as $field => $component) {
|
||||
if (isset($component['type']) && ($component['type'] === 'comment_default')) {
|
||||
if ($component['settings']['view_mode'] === $display->getMode()) {
|
||||
$view_display->removeComponent($field);
|
||||
/** @var \Drupal\Core\Entity\EntityViewModeInterface $mode */
|
||||
$mode = EntityViewMode::load($display->getTargetEntityTypeId() . '.' . $display->getMode());
|
||||
$arguments = [
|
||||
'@id' => $view_display->id(),
|
||||
'@name' => $field,
|
||||
'@display' => $mode->label(),
|
||||
'@mode' => $display->getMode(),
|
||||
];
|
||||
\Drupal::logger('system')->warning("View display '@id': Comment field formatter '@name' was disabled because it is using the comment view display '@display' (@mode) that was just disabled.", $arguments);
|
||||
$changed = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($changed) {
|
||||
$view_display->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
use Drupal\Core\Datetime\Entity\DateFormat;
|
||||
use Drupal\Core\Entity\ContentEntityInterface;
|
||||
use Drupal\Core\Entity\FieldableEntityInterface;
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
|
||||
/**
|
||||
|
@ -19,15 +21,28 @@ function comment_token_info() {
|
|||
'needs-data' => 'comment',
|
||||
);
|
||||
|
||||
// @todo Make this work per field. See https://www.drupal.org/node/2031903.
|
||||
$entity['comment-count'] = array(
|
||||
'name' => t("Comment count"),
|
||||
'description' => t("The number of comments posted on an entity."),
|
||||
);
|
||||
$entity['comment-count-new'] = array(
|
||||
'name' => t("New comment count"),
|
||||
'description' => t("The number of comments posted on an entity since the reader last viewed it."),
|
||||
);
|
||||
$tokens = [];
|
||||
// Provide a integration for each entity type except comment.
|
||||
foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type_id => $entity_type) {
|
||||
if ($entity_type_id == 'comment' || !$entity_type->isSubclassOf(ContentEntityInterface::class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (\Drupal::service('comment.manager')->getFields($entity_type_id)) {
|
||||
// Get the correct token type.
|
||||
$token_type = ($entity_type_id == 'taxonomy_term') ? 'term' : $entity_type_id;
|
||||
|
||||
// @todo Make this work per field. See https://www.drupal.org/node/2031903.
|
||||
$tokens[$token_type]['comment-count'] = [
|
||||
'name' => t("Comment count"),
|
||||
'description' => t("The number of comments posted on an entity."),
|
||||
];
|
||||
$tokens[$token_type]['comment-count-new'] = [
|
||||
'name' => t("New comment count"),
|
||||
'description' => t("The number of comments posted on an entity since the reader last viewed it."),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Core comment tokens
|
||||
$comment['cid'] = array(
|
||||
|
@ -97,9 +112,8 @@ function comment_token_info() {
|
|||
return array(
|
||||
'types' => array('comment' => $type),
|
||||
'tokens' => array(
|
||||
'entity' => $entity,
|
||||
'comment' => $comment,
|
||||
),
|
||||
) + $tokens,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -235,9 +249,10 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM
|
|||
$replacements += $token_service->generate('user', $author_tokens, array('user' => $account), $options, $bubbleable_metadata);
|
||||
}
|
||||
}
|
||||
elseif ($type == 'entity' & !empty($data['entity'])) {
|
||||
// Replacement tokens for any content entities that have comment field.
|
||||
elseif (!empty($data[$type]) && $data[$type] instanceof FieldableEntityInterface) {
|
||||
/** @var $entity \Drupal\Core\Entity\FieldableEntityInterface */
|
||||
$entity = $data['entity'];
|
||||
$entity = $data[$type];
|
||||
|
||||
foreach ($tokens as $name => $original) {
|
||||
switch ($name) {
|
||||
|
|
|
@ -173,7 +173,7 @@ display:
|
|||
entity_field: changed
|
||||
filters:
|
||||
status:
|
||||
value: true
|
||||
value: '1'
|
||||
table: comment_field_data
|
||||
field: status
|
||||
id: status
|
||||
|
@ -184,7 +184,7 @@ display:
|
|||
entity_type: comment
|
||||
entity_field: status
|
||||
status_node:
|
||||
value: true
|
||||
value: '1'
|
||||
table: node_field_data
|
||||
field: status
|
||||
relationship: node
|
||||
|
|
|
@ -4,6 +4,9 @@ field.formatter.settings.comment_default:
|
|||
type: mapping
|
||||
label: 'Comment display format settings'
|
||||
mapping:
|
||||
view_mode:
|
||||
type: string
|
||||
label: 'The comment entity view mode to be used in this formatter'
|
||||
pager_id:
|
||||
type: integer
|
||||
label: 'Pager ID'
|
||||
|
|
|
@ -32,7 +32,7 @@ interface CommentInterface extends ContentEntityInterface, EntityChangedInterfac
|
|||
/**
|
||||
* Returns the parent comment entity if this is a reply to a comment.
|
||||
*
|
||||
* @return \Drupal\comment\CommentInterface|NULL
|
||||
* @return \Drupal\comment\CommentInterface|null
|
||||
* A comment entity of the parent comment or NULL if there is no parent.
|
||||
*/
|
||||
public function getParentComment();
|
||||
|
|
|
@ -79,8 +79,7 @@ class CommentController extends ControllerBase {
|
|||
* @param \Drupal\comment\CommentInterface $comment
|
||||
* A comment entity.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse.
|
||||
* Redirects to the permalink URL for this comment.
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function commentApprove(CommentInterface $comment) {
|
||||
$comment->setPublished(TRUE);
|
||||
|
@ -125,9 +124,8 @@ class CommentController extends ControllerBase {
|
|||
// Find the current display page for this comment.
|
||||
$page = $this->entityManager()->getStorage('comment')->getDisplayOrdinal($comment, $field_definition->getSetting('default_mode'), $field_definition->getSetting('per_page'));
|
||||
// @todo: Cleaner sub request handling.
|
||||
$subrequest_url = $entity->urlInfo()->toString(TRUE);
|
||||
$subrequest_url = $entity->urlInfo()->setOption('query', ['page' => $page])->toString(TRUE);
|
||||
$redirect_request = Request::create($subrequest_url->getGeneratedUrl(), 'GET', $request->query->all(), $request->cookies->all(), array(), $request->server->all());
|
||||
$redirect_request->query->set('page', $page);
|
||||
// Carry over the session to the subrequest.
|
||||
if ($session = $request->getSession()) {
|
||||
$redirect_request->setSession($session);
|
||||
|
|
|
@ -208,16 +208,18 @@ class Comment extends ContentEntityBase implements CommentInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
|
||||
$fields['cid'] = BaseFieldDefinition::create('integer')
|
||||
->setLabel(t('Comment ID'))
|
||||
->setDescription(t('The comment ID.'))
|
||||
->setReadOnly(TRUE)
|
||||
->setSetting('unsigned', TRUE);
|
||||
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
|
||||
$fields = parent::baseFieldDefinitions($entity_type);
|
||||
|
||||
$fields['uuid'] = BaseFieldDefinition::create('uuid')
|
||||
->setLabel(t('UUID'))
|
||||
->setDescription(t('The comment UUID.'))
|
||||
->setReadOnly(TRUE);
|
||||
$fields['cid']->setLabel(t('Comment ID'))
|
||||
->setDescription(t('The comment ID.'));
|
||||
|
||||
$fields['uuid']->setDescription(t('The comment UUID.'));
|
||||
|
||||
$fields['comment_type']->setLabel(t('Comment Type'))
|
||||
->setDescription(t('The comment type.'));
|
||||
|
||||
$fields['langcode']->setDescription(t('The comment language code.'));
|
||||
|
||||
$fields['pid'] = BaseFieldDefinition::create('entity_reference')
|
||||
->setLabel(t('Parent ID'))
|
||||
|
@ -229,18 +231,6 @@ class Comment extends ContentEntityBase implements CommentInterface {
|
|||
->setDescription(t('The ID of the entity of which this comment is a reply.'))
|
||||
->setRequired(TRUE);
|
||||
|
||||
$fields['langcode'] = BaseFieldDefinition::create('language')
|
||||
->setLabel(t('Language'))
|
||||
->setDescription(t('The comment language code.'))
|
||||
->setTranslatable(TRUE)
|
||||
->setDisplayOptions('view', array(
|
||||
'type' => 'hidden',
|
||||
))
|
||||
->setDisplayOptions('form', array(
|
||||
'type' => 'language_select',
|
||||
'weight' => 2,
|
||||
));
|
||||
|
||||
$fields['subject'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Subject'))
|
||||
->setTranslatable(TRUE)
|
||||
|
@ -312,11 +302,6 @@ class Comment extends ContentEntityBase implements CommentInterface {
|
|||
->setSetting('is_ascii', TRUE)
|
||||
->setSetting('max_length', EntityTypeInterface::ID_MAX_LENGTH);
|
||||
|
||||
$fields['comment_type'] = BaseFieldDefinition::create('entity_reference')
|
||||
->setLabel(t('Comment Type'))
|
||||
->setDescription(t('The comment type.'))
|
||||
->setSetting('target_type', 'comment_type');
|
||||
|
||||
$fields['field_name'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Comment field name'))
|
||||
->setDescription(t('The field name through which this comment was added.'))
|
||||
|
|
|
@ -151,10 +151,10 @@ class CommentAdminOverview extends FormBase {
|
|||
'operations' => $this->t('Operations'),
|
||||
);
|
||||
$cids = $this->commentStorage->getQuery()
|
||||
->condition('status', $status)
|
||||
->tableSort($header)
|
||||
->pager(50)
|
||||
->execute();
|
||||
->condition('status', $status)
|
||||
->tableSort($header)
|
||||
->pager(50)
|
||||
->execute();
|
||||
|
||||
/** @var $comments \Drupal\comment\CommentInterface[] */
|
||||
$comments = $this->commentStorage->loadMultiple($cids);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Drupal\comment\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityFormBuilderInterface;
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
|
@ -36,6 +37,7 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP
|
|||
*/
|
||||
public static function defaultSettings() {
|
||||
return array(
|
||||
'view_mode' => 'default',
|
||||
'pager_id' => 0,
|
||||
) + parent::defaultSettings();
|
||||
}
|
||||
|
@ -167,7 +169,7 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP
|
|||
$comments_per_page = $comment_settings['per_page'];
|
||||
$comments = $this->storage->loadThread($entity, $field_name, $mode, $comments_per_page, $this->getSetting('pager_id'));
|
||||
if ($comments) {
|
||||
$build = $this->viewBuilder->viewMultiple($comments);
|
||||
$build = $this->viewBuilder->viewMultiple($comments, $this->getSetting('view_mode'));
|
||||
$build['pager']['#type'] = 'pager';
|
||||
// CommentController::commentPermalink() calculates the page number
|
||||
// where a specific comment appears and does a subrequest pointing to
|
||||
|
@ -217,6 +219,16 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP
|
|||
*/
|
||||
public function settingsForm(array $form, FormStateInterface $form_state) {
|
||||
$element = array();
|
||||
$view_modes = $this->getViewModes();
|
||||
$element['view_mode'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Comments view mode'),
|
||||
'#description' => $this->t('Select the view mode used to show the list of comments.'),
|
||||
'#default_value' => $this->getSetting('view_mode'),
|
||||
'#options' => $view_modes,
|
||||
// Only show the select element when there are more than one options.
|
||||
'#access' => count($view_modes) > 1,
|
||||
];
|
||||
$element['pager_id'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Pager ID'),
|
||||
|
@ -231,13 +243,41 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function settingsSummary() {
|
||||
// Only show a summary if we're using a non-standard pager id.
|
||||
if ($this->getSetting('pager_id')) {
|
||||
return array($this->t('Pager ID: @id', array(
|
||||
'@id' => $this->getSetting('pager_id'),
|
||||
)));
|
||||
$view_mode = $this->getSetting('view_mode');
|
||||
$view_modes = $this->getViewModes();
|
||||
$view_mode_label = isset($view_modes[$view_mode]) ? $view_modes[$view_mode] : 'default';
|
||||
$summary = [$this->t('Comment view mode: @mode', ['@mode' => $view_mode_label])];
|
||||
if ($pager_id = $this->getSetting('pager_id')) {
|
||||
$summary[] = $this->t('Pager ID: @id', ['@id' => $pager_id]);
|
||||
}
|
||||
return array();
|
||||
return $summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function calculateDependencies() {
|
||||
$dependencies = parent::calculateDependencies();
|
||||
if ($mode = $this->getSetting('view_mode')) {
|
||||
if ($bundle = $this->getFieldSetting('comment_type')) {
|
||||
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */
|
||||
if ($display = EntityViewDisplay::load("comment.$bundle.$mode")) {
|
||||
$dependencies[$display->getConfigDependencyKey()][] = $display->getConfigDependencyName();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of comment view modes for the configured comment type.
|
||||
*
|
||||
* @return array
|
||||
* Associative array keyed by view mode key and having the view mode label
|
||||
* as value.
|
||||
*/
|
||||
protected function getViewModes() {
|
||||
return $this->entityManager->getViewModeOptionsByBundle('comment', $this->getFieldSetting('comment_type'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,12 +29,12 @@ class CommentActionsTest extends CommentTestBase {
|
|||
$comment = $this->postComment($this->node, $comment_text, $subject);
|
||||
|
||||
// Unpublish a comment.
|
||||
$action = entity_load('action', 'comment_unpublish_action');
|
||||
$action = Action::load('comment_unpublish_action');
|
||||
$action->execute(array($comment));
|
||||
$this->assertTrue($comment->isPublished() === FALSE, 'Comment was unpublished');
|
||||
|
||||
// Publish a comment.
|
||||
$action = entity_load('action', 'comment_publish_action');
|
||||
$action = Action::load('comment_publish_action');
|
||||
$action->execute(array($comment));
|
||||
$this->assertTrue($comment->isPublished() === TRUE, 'Comment was published');
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@ namespace Drupal\comment\Tests;
|
|||
use Drupal\comment\CommentManagerInterface;
|
||||
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
|
||||
use Drupal\comment\Entity\Comment;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\Core\Entity\Entity\EntityViewMode;
|
||||
use Drupal\user\RoleInterface;
|
||||
use Drupal\filter\Entity\FilterFormat;
|
||||
|
||||
|
@ -292,4 +295,53 @@ class CommentInterfaceTest extends CommentTestBase {
|
|||
$this->assertEqual('(No subject)', Comment::load(2)->getSubject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the comment formatter configured with a custom comment view mode.
|
||||
*/
|
||||
public function testViewMode() {
|
||||
$this->drupalLogin($this->webUser);
|
||||
$this->drupalGet($this->node->toUrl());
|
||||
$comment_text = $this->randomMachineName();
|
||||
// Post a comment.
|
||||
$this->postComment($this->node, $comment_text);
|
||||
|
||||
// Comment displayed in 'default' display mode found and has body text.
|
||||
$comment_element = $this->cssSelect('.comment-wrapper');
|
||||
$this->assertTrue(!empty($comment_element));
|
||||
$this->assertRaw('<p>' . $comment_text . '</p>');
|
||||
|
||||
// Create a new comment entity view mode.
|
||||
$mode = Unicode::strtolower($this->randomMachineName());
|
||||
EntityViewMode::create([
|
||||
'targetEntityType' => 'comment',
|
||||
'id' => "comment.$mode",
|
||||
])->save();
|
||||
// Create the corresponding entity view display for article node-type. Note
|
||||
// that this new view display mode doesn't contain the comment body.
|
||||
EntityViewDisplay::create([
|
||||
'targetEntityType' => 'comment',
|
||||
'bundle' => 'comment',
|
||||
'mode' => $mode,
|
||||
])->setStatus(TRUE)->save();
|
||||
|
||||
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $node_display */
|
||||
$node_display = EntityViewDisplay::load('node.article.default');
|
||||
$formatter = $node_display->getComponent('comment');
|
||||
// Change the node comment field formatter to use $mode mode instead of
|
||||
// 'default' mode.
|
||||
$formatter['settings']['view_mode'] = $mode;
|
||||
$node_display
|
||||
->setComponent('comment', $formatter)
|
||||
->save();
|
||||
|
||||
// Reloading the node page to show the same node with its same comment but
|
||||
// with a different display mode.
|
||||
$this->drupalGet($this->node->toUrl());
|
||||
// The comment should exist but without the body text because we used $mode
|
||||
// mode this time.
|
||||
$comment_element = $this->cssSelect('.comment-wrapper');
|
||||
$this->assertTrue(!empty($comment_element));
|
||||
$this->assertNoRaw('<p>' . $comment_text . '</p>');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class CommentLinksTest extends CommentTestBase {
|
|||
'subject' => $this->randomMachineName(),
|
||||
'hostname' => '127.0.0.1',
|
||||
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
|
||||
'comment_body' => array(LanguageInterface::LANGCODE_NOT_SPECIFIED => array($this->randomMachineName())),
|
||||
'comment_body' => array(array('value' => $this->randomMachineName())),
|
||||
));
|
||||
$comment->save();
|
||||
$this->comment = $comment;
|
||||
|
@ -101,6 +101,26 @@ class CommentLinksTest extends CommentTestBase {
|
|||
$this->assertLink('Add new comment');
|
||||
}
|
||||
|
||||
// Change weight to make links go before comment body.
|
||||
entity_get_display('comment', 'comment', 'default')
|
||||
->setComponent('links', array('weight' => -100))
|
||||
->save();
|
||||
$this->drupalGet($this->node->urlInfo());
|
||||
$element = $this->cssSelect('article.js-comment > div');
|
||||
// Get last child element.
|
||||
$element = end($element[0]);
|
||||
$this->assertIdentical($element[0]->getName(), 'div', 'Last element is comment body.');
|
||||
|
||||
// Change weight to make links go after comment body.
|
||||
entity_get_display('comment', 'comment', 'default')
|
||||
->setComponent('links', array('weight' => 100))
|
||||
->save();
|
||||
$this->drupalGet($this->node->urlInfo());
|
||||
$element = $this->cssSelect('article.js-comment > div');
|
||||
// Get last child element.
|
||||
$element = end($element[0]);
|
||||
$this->assertIdentical($element[0]->getName(), 'ul', 'Last element is comment links.');
|
||||
|
||||
// Make sure we can hide node links.
|
||||
entity_get_display('node', $this->node->bundle(), 'default')
|
||||
->removeComponent('links')
|
||||
|
|
|
@ -90,6 +90,38 @@ class CommentPagerTest extends CommentTestBase {
|
|||
$this->drupalLogout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirms comment paging works correctly with flat and threaded comments.
|
||||
*/
|
||||
function testCommentPermalink() {
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Set comment variables.
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(TRUE);
|
||||
$this->setCommentPreview(DRUPAL_DISABLED);
|
||||
|
||||
// Create a node and three comments.
|
||||
$node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
|
||||
$comments = array();
|
||||
$comments[] = $this->postComment($node, 'comment 1: ' . $this->randomMachineName(), $this->randomMachineName(), TRUE);
|
||||
$comments[] = $this->postComment($node, 'comment 2: ' . $this->randomMachineName(), $this->randomMachineName(), TRUE);
|
||||
$comments[] = $this->postComment($node, 'comment 3: ' . $this->randomMachineName(), $this->randomMachineName(), TRUE);
|
||||
|
||||
$this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.');
|
||||
|
||||
// Set comments to one per page so that we are able to test paging without
|
||||
// needing to insert large numbers of comments.
|
||||
$this->setCommentsPerPage(1);
|
||||
|
||||
// Navigate to each comment permalink as anonymous and assert it appears on
|
||||
// the page.
|
||||
foreach ($comments as $index => $comment) {
|
||||
$this->drupalGet($comment->toUrl());
|
||||
$this->assertTrue($this->commentExists($comment), sprintf('Comment %d appears on page %d.', $index + 1, $index + 1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests comment ordering and threading.
|
||||
*/
|
||||
|
@ -283,6 +315,7 @@ class CommentPagerTest extends CommentTestBase {
|
|||
'weight' => 30,
|
||||
'settings' => array(
|
||||
'pager_id' => 1,
|
||||
'view_mode' => 'default',
|
||||
)
|
||||
))
|
||||
->save();
|
||||
|
|
|
@ -111,7 +111,7 @@ abstract class CommentTestBase extends WebTestBase {
|
|||
$edit['comment_body[0][value]'] = $comment;
|
||||
|
||||
if ($entity !== NULL) {
|
||||
$field = FieldConfig::loadByName('node', $entity->bundle(), $field_name);
|
||||
$field = FieldConfig::loadByName($entity->getEntityTypeId(), $entity->bundle(), $field_name);
|
||||
}
|
||||
else {
|
||||
$field = FieldConfig::loadByName('node', 'article', $field_name);
|
||||
|
@ -120,7 +120,7 @@ abstract class CommentTestBase extends WebTestBase {
|
|||
|
||||
// Must get the page before we test for fields.
|
||||
if ($entity !== NULL) {
|
||||
$this->drupalGet('comment/reply/node/' . $entity->id() . '/' . $field_name);
|
||||
$this->drupalGet('comment/reply/' . $entity->getEntityTypeId() . '/' . $entity->id() . '/' . $field_name);
|
||||
}
|
||||
|
||||
// Determine the visibility of subject form field.
|
||||
|
|
|
@ -29,8 +29,11 @@ trait CommentTestTrait {
|
|||
* CommentItemInterface::OPEN.
|
||||
* @param string $comment_type_id
|
||||
* (optional) ID of comment type to use. Defaults to 'comment'.
|
||||
* @param string $comment_view_mode
|
||||
* (optional) The comment view mode to be used in comment field formatter.
|
||||
* Defaults to 'full'.
|
||||
*/
|
||||
public function addDefaultCommentField($entity_type, $bundle, $field_name = 'comment', $default_value = CommentItemInterface::OPEN, $comment_type_id = 'comment') {
|
||||
public function addDefaultCommentField($entity_type, $bundle, $field_name = 'comment', $default_value = CommentItemInterface::OPEN, $comment_type_id = 'comment', $comment_view_mode = 'full') {
|
||||
$entity_manager = \Drupal::entityManager();
|
||||
// Create the comment type if needed.
|
||||
$comment_type_storage = $entity_manager->getStorage('comment_type');
|
||||
|
@ -106,6 +109,7 @@ trait CommentTestTrait {
|
|||
'label' => 'above',
|
||||
'type' => 'comment_default',
|
||||
'weight' => 20,
|
||||
'settings' => array('view_mode' => $comment_view_mode),
|
||||
))
|
||||
->save();
|
||||
foreach ($entity_manager->getViewModes($entity_type) as $id => $view_mode) {
|
||||
|
|
|
@ -59,6 +59,12 @@ class CommentTitleTest extends CommentTestBase {
|
|||
$this->assertTrue($this->commentExists($comment1), 'Comment #1. Comment found.');
|
||||
// Tests that markup is created for comment with heading.
|
||||
$this->assertPattern('|<h3[^>]*><a[^>]*>' . $subject_text . '</a></h3>|', 'Comment title is rendered in h3 when title populated.');
|
||||
// Tests that the comment's title link is the permalink of the comment.
|
||||
$comment_permalink = $this->cssSelect('.permalink');
|
||||
$comment_permalink = (string) $comment_permalink[0]['href'];
|
||||
// Tests that the comment's title link contains the url fragment.
|
||||
$this->assertTrue(strpos($comment_permalink, '#comment-' . $comment1->id()), "The comment's title link contains the url fragment.");
|
||||
$this->assertEqual($comment1->permalink()->toString(), $comment_permalink, "The comment's title has the correct link.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,12 +2,16 @@
|
|||
|
||||
namespace Drupal\comment\Tests;
|
||||
|
||||
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
use Drupal\comment\Entity\Comment;
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\user\Entity\User;
|
||||
|
||||
/**
|
||||
* Generates text using placeholders for dummy content to check comment token
|
||||
|
@ -16,6 +20,12 @@ use Drupal\node\Entity\Node;
|
|||
* @group comment
|
||||
*/
|
||||
class CommentTokenReplaceTest extends CommentTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy'];
|
||||
|
||||
/**
|
||||
* Creates a comment, then tests the tokens generated from it.
|
||||
*/
|
||||
|
@ -27,6 +37,12 @@ class CommentTokenReplaceTest extends CommentTestBase {
|
|||
'language' => $language_interface,
|
||||
);
|
||||
|
||||
// Setup vocabulary.
|
||||
Vocabulary::create([
|
||||
'vid' => 'tags',
|
||||
'name' => 'Tags',
|
||||
])->save();
|
||||
|
||||
// Change the title of the admin user.
|
||||
$this->adminUser->name->value = 'This is a title with some special & > " stuff.';
|
||||
$this->adminUser->save();
|
||||
|
@ -122,18 +138,43 @@ class CommentTokenReplaceTest extends CommentTestBase {
|
|||
$input = '[comment:author]';
|
||||
$output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId()));
|
||||
$this->assertEqual($output, Html::escape($author_name), format_string('Comment author token %token replaced.', array('%token' => $input)));
|
||||
// Add comment field to user and term entities.
|
||||
$this->addDefaultCommentField('user', 'user', 'comment', CommentItemInterface::OPEN, 'comment_user');
|
||||
$this->addDefaultCommentField('taxonomy_term', 'tags', 'comment', CommentItemInterface::OPEN, 'comment_term');
|
||||
|
||||
// Load node so comment_count gets computed.
|
||||
// Create a user and a comment.
|
||||
$user = User::create(['name' => 'alice']);
|
||||
$user->save();
|
||||
$this->postComment($user, 'user body', 'user subject', TRUE);
|
||||
|
||||
// Create a term and a comment.
|
||||
$term = Term::create([
|
||||
'vid' => 'tags',
|
||||
'name' => 'term',
|
||||
]);
|
||||
$term->save();
|
||||
$this->postComment($term, 'term body', 'term subject', TRUE);
|
||||
|
||||
// Load node, user and term again so comment_count gets computed.
|
||||
$node = Node::load($node->id());
|
||||
$user = User::load($user->id());
|
||||
$term = Term::load($term->id());
|
||||
|
||||
// Generate comment tokens for the node (it has 2 comments, both new).
|
||||
// Generate comment tokens for node (it has 2 comments, both new),
|
||||
// user and term.
|
||||
$tests = array();
|
||||
$tests['[entity:comment-count]'] = 2;
|
||||
$tests['[entity:comment-count-new]'] = 2;
|
||||
$tests['[node:comment-count]'] = 2;
|
||||
$tests['[node:comment-count-new]'] = 2;
|
||||
$tests['[user:comment-count]'] = 1;
|
||||
$tests['[user:comment-count-new]'] = 1;
|
||||
$tests['[term:comment-count]'] = 1;
|
||||
$tests['[term:comment-count-new]'] = 1;
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = $token_service->replace($input, array('entity' => $node, 'node' => $node), array('langcode' => $language_interface->getId()));
|
||||
$this->assertEqual($output, $expected, format_string('Node comment token %token replaced.', array('%token' => $input)));
|
||||
$output = $token_service->replace($input, ['entity' => $node, 'node' => $node, 'user' => $user, 'term' => $term], ['langcode' => $language_interface->getId()]);
|
||||
$this->assertEqual($output, $expected, format_string('Comment token %token replaced.', ['%token' => $input]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,10 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doTestAuthoringInfo() {
|
||||
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
||||
$storage = $this->container->get('entity_type.manager')
|
||||
->getStorage($this->entityTypeId);
|
||||
$storage->resetCache([$this->entityId]);
|
||||
$entity = $storage->load($this->entityId);
|
||||
$languages = $this->container->get('language_manager')->getLanguages();
|
||||
$values = array();
|
||||
|
||||
|
@ -166,7 +169,8 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
|
|||
$this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode));
|
||||
}
|
||||
|
||||
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
||||
$storage->resetCache([$this->entityId]);
|
||||
$entity = $storage->load($this->entityId);
|
||||
foreach ($this->langcodes as $langcode) {
|
||||
$metadata = $this->manager->getTranslationMetadata($entity->getTranslation($langcode));
|
||||
$this->assertEqual($metadata->getAuthor()->id(), $values[$langcode]['uid'], 'Translation author correctly stored.');
|
||||
|
@ -195,7 +199,10 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doTestTranslationEdit() {
|
||||
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
||||
$storage = $this->container->get('entity_type.manager')
|
||||
->getStorage($this->entityTypeId);
|
||||
$storage->resetCache([$this->entityId]);
|
||||
$entity = $storage->load($this->entityId);
|
||||
$languages = $this->container->get('language_manager')->getLanguages();
|
||||
|
||||
foreach ($this->langcodes as $langcode) {
|
||||
|
|
53
core/modules/comment/src/Tests/Update/CommentUpdateTest.php
Normal file
53
core/modules/comment/src/Tests/Update/CommentUpdateTest.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\comment\Tests\Update;
|
||||
|
||||
use Drupal\system\Tests\Update\UpdatePathTestBase;
|
||||
|
||||
/**
|
||||
* Tests that comment settings are properly updated during database updates.
|
||||
*
|
||||
* @group comment
|
||||
*/
|
||||
class CommentUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8-rc1.filled.standard.php.gz',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests comment_update_8200().
|
||||
*
|
||||
* @see comment_update_8200()
|
||||
*/
|
||||
public function testCommentUpdate8101() {
|
||||
// Load the 'node.article.default' entity view display config, and check
|
||||
// that component 'comment' does not contain the 'view_mode' setting.
|
||||
$config = $this->config('core.entity_view_display.node.article.default');
|
||||
$this->assertNull($config->get('content.comment.settings.view_mode'));
|
||||
|
||||
// Load the 'node.forum.default' entity view display config, and check that
|
||||
// component 'comment_forum' does not contain the 'view_mode' setting.
|
||||
$config = $this->config('core.entity_view_display.node.forum.default');
|
||||
$this->assertNull($config->get('content.comment_forum.settings.view_mode'));
|
||||
|
||||
// Run updates.
|
||||
$this->runUpdates();
|
||||
|
||||
// Check that 'node.article.default' entity view display setting 'view_mode'
|
||||
// has the value 'default'.
|
||||
$config = $this->config('core.entity_view_display.node.article.default');
|
||||
$this->assertIdentical($config->get('content.comment.settings.view_mode'), 'default');
|
||||
|
||||
// Check that 'node.forum.default' entity view display setting 'view_mode'
|
||||
// has the value 'default'.
|
||||
$config = $this->config('core.entity_view_display.node.forum.default');
|
||||
$this->assertIdentical($config->get('content.comment_forum.settings.view_mode'), 'default');
|
||||
}
|
||||
|
||||
}
|
|
@ -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