diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php index 6276f95..ac61f07 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldFormatter; use Drupal\Component\Utility\SafeMarkup; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\RevisionableInterface; use Drupal\Core\Field\FieldDefinitionInterface; @@ -123,8 +124,7 @@ public function viewElements(FieldItemListInterface $items) { $elements = array(); $url = NULL; if ($this->getSetting('link_to_entity')) { - // For the default revision this falls back to 'canonical' - $url = $items->getEntity()->urlInfo('revision'); + $url = $this->getEntityUrl($items->getEntity()); } foreach ($items as $delta => $item) { @@ -158,4 +158,21 @@ protected function viewValue(FieldItemInterface $item) { return nl2br(SafeMarkup::checkPlain($item->value)); } + /** + * Gets the URI elements of the entity. + * + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity object. + * + * @return \Drupal\Core\Url + * The URI elements of the entity. + */ + protected function getEntityUrl(EntityInterface $entity) { + if (class_exists('Drupal\comment\Entity\Comment') && $entity instanceof \Drupal\comment\CommentInterface) { + return $entity->permalink(); + } + // For the default revision this falls back to 'canonical' + return $entity->urlInfo('revision'); + } + } diff --git a/core/modules/comment/comment.routing.yml b/core/modules/comment/comment.routing.yml index 6a76f96..91c81bb 100644 --- a/core/modules/comment/comment.routing.yml +++ b/core/modules/comment/comment.routing.yml @@ -2,7 +2,7 @@ comment.admin: path: '/admin/content/comment' defaults: _title: 'Comments' - _form: 'Drupal\comment\Form\CommentAdminOverview' + _form: '\Drupal\comment\Form\CommentAdminOverview' type: 'new' requirements: _permission: 'administer comments' @@ -11,7 +11,7 @@ comment.admin_approval: path: '/admin/content/comment/approval' defaults: _title: 'Unapproved comments' - _form: 'Drupal\comment\Form\CommentAdminOverview' + _form: '\Drupal\comment\Form\CommentAdminOverview' type: 'approval' requirements: _permission: 'administer comments' diff --git a/core/modules/comment/config/optional/views.view.comment.yml b/core/modules/comment/config/optional/views.view.comment.yml index 5581c4d..b5b65fd 100644 --- a/core/modules/comment/config/optional/views.view.comment.yml +++ b/core/modules/comment/config/optional/views.view.comment.yml @@ -17,7 +17,7 @@ display: display_plugin: default id: default display_title: Master - position: 1 + position: 0 display_options: access: type: perm @@ -79,10 +79,9 @@ display: comment_bulk_form: comment_bulk_form subject: subject name: name + commented_entity_label: commented_entity_label changed: changed - edit_comment: edit_comment - delete_comment: delete_comment - dropbutton: dropbutton + operations: operations info: comment_bulk_form: align: '' @@ -103,28 +102,21 @@ display: separator: '' empty_column: false responsive: priority-medium - changed: - sortable: true - default_sort_order: desc - align: '' - separator: '' - empty_column: false - responsive: priority-low - edit_comment: + commented_entity_label: sortable: false default_sort_order: asc align: '' separator: '' empty_column: false responsive: '' - delete_comment: - sortable: false - default_sort_order: asc + changed: + sortable: true + default_sort_order: desc align: '' separator: '' empty_column: false - responsive: '' - dropbutton: + responsive: priority-low + operations: sortable: false default_sort_order: asc align: '' @@ -649,12 +641,349 @@ display: defaults: filters: false filter_groups: false - fields: true - filter_groups: - operator: AND - groups: - 1: AND + fields: false display_extenders: { } + fields: + comment_bulk_form: + id: comment_bulk_form + table: comment + field: comment_bulk_form + relationship: none + group_type: group + admin_label: '' + label: '' + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + action_title: 'Update Options' + include_exclude: include + selected_actions: + - comment_delete_action + - comment_publish_action + plugin_id: comment_bulk_form + entity_type: comment + subject: + id: subject + table: comment_field_data + field: subject + relationship: none + group_type: group + admin_label: '' + label: Subject + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: string + settings: + link_to_entity: true + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + entity_type: comment + entity_field: subject + plugin_id: field + name: + id: name + table: comment_field_data + field: name + relationship: none + group_type: group + admin_label: '' + label: Author + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: comment_username + settings: { } + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + entity_type: comment + entity_field: name + plugin_id: field + commented_entity_label: + id: commented_entity_label + table: comment + field: commented_entity_label + relationship: none + group_type: group + admin_label: '' + label: 'Posted in' + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + link_to_entity: true + entity_type: comment + plugin_id: commented_entity_label + changed: + id: changed + table: comment_field_data + field: changed + relationship: none + group_type: group + admin_label: '' + label: Updated + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + date_format: short + custom_date_format: '' + timezone: '' + entity_type: comment + entity_field: changed + plugin_id: date + operations: + id: operations + table: comment + field: operations + relationship: none + group_type: group + admin_label: '' + label: Operations + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + destination: true + entity_type: comment + plugin_id: entity_operations cache_metadata: contexts: - 'languages:language_content' diff --git a/core/modules/comment/src/Controller/AdminController.php b/core/modules/comment/src/Controller/AdminController.php deleted file mode 100644 index 76becb8..0000000 --- a/core/modules/comment/src/Controller/AdminController.php +++ /dev/null @@ -1,65 +0,0 @@ -commentManager = $comment_manager; - $this->formBuilder = $form_builder; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('comment.manager'), - $container->get('form_builder') - ); - } - - /** - * Presents an administrative comment listing. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * The request of the page. - * @param string $type - * The type of the overview form ('approval' or 'new') default to 'new'. - * - * @return array - * Then comment multiple delete confirmation form or the comments overview - * administration form. - */ - public function adminPage(Request $request, $type = 'new') { - if ($request->request->get('operation') == 'delete' && $request->request->get('comments')) { - return $this->formBuilder->getForm('\Drupal\comment\Form\ConfirmDeleteMultiple', $request); - } - else { - return $this->formBuilder->getForm('\Drupal\comment\Form\CommentAdminOverview', $type); - } - } - -} diff --git a/core/modules/comment/src/Form/CommentAdminOverview.php b/core/modules/comment/src/Form/CommentAdminOverview.php index bdd36f8..070f452 100644 --- a/core/modules/comment/src/Form/CommentAdminOverview.php +++ b/core/modules/comment/src/Form/CommentAdminOverview.php @@ -8,9 +8,7 @@ namespace Drupal\comment\Form; use Drupal\comment\CommentInterface; -use Drupal\comment\CommentStorageInterface; use Drupal\Component\Utility\Unicode; -use Drupal\Core\Cache\Cache; use Drupal\Core\Datetime\DateFormatter; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; @@ -65,8 +63,6 @@ class CommentAdminOverview extends FormBase { * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager service. - * @param \Drupal\comment\CommentStorageInterface $comment_storage - * The comment storage. * @param \Drupal\Core\Datetime\DateFormatter $date_formatter * The date formatter service. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler @@ -74,9 +70,9 @@ class CommentAdminOverview extends FormBase { * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory * The tempstore factory. */ - public function __construct(EntityManagerInterface $entity_manager, CommentStorageInterface $comment_storage, DateFormatter $date_formatter, ModuleHandlerInterface $module_handler, PrivateTempStoreFactory $temp_store_factory) { + public function __construct(EntityManagerInterface $entity_manager, DateFormatter $date_formatter, ModuleHandlerInterface $module_handler, PrivateTempStoreFactory $temp_store_factory) { $this->entityManager = $entity_manager; - $this->commentStorage = $comment_storage; + $this->commentStorage = $entity_manager->getStorage('comment'); $this->dateFormatter = $date_formatter; $this->moduleHandler = $module_handler; $this->tempStoreFactory = $temp_store_factory; @@ -88,7 +84,6 @@ public function __construct(EntityManagerInterface $entity_manager, CommentStora public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), - $container->get('entity.manager')->getStorage('comment'), $container->get('date.formatter'), $container->get('module_handler'), $container->get('user.private_tempstore') @@ -279,9 +274,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $comments = $this->commentStorage->loadMultiple($cids); if ($operation != 'delete') { foreach ($comments as $comment) { - // Delete operation handled in - // \Drupal\comment\Form\ConfirmDeleteMultiple - // @see \Drupal\comment\Controller\AdminController::adminPage(). if ($operation == 'unpublish') { $comment->setPublished(FALSE); } @@ -292,7 +284,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) { } drupal_set_message($this->t('The update has been performed.')); $form_state->setRedirect('comment.admin'); - Cache::invalidateTags(['content']); } else { $this->tempStoreFactory diff --git a/core/modules/comment/src/Plugin/Action/DeleteComment.php b/core/modules/comment/src/Plugin/Action/DeleteComment.php index 29a23b9..ee759f3 100644 --- a/core/modules/comment/src/Plugin/Action/DeleteComment.php +++ b/core/modules/comment/src/Plugin/Action/DeleteComment.php @@ -14,7 +14,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Unpublishes a comment. + * Deletes a comment. * * @Action( * id = "comment_delete_action", @@ -87,9 +87,9 @@ public function execute($entity = NULL) { /** * {@inheritdoc} */ - public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { + public function access($comment, AccountInterface $account = NULL, $return_as_object = FALSE) { /** @var \Drupal\comment\CommentInterface $object */ - return $object->access('delete', $account, $return_as_object); + return $comment->access('delete', $account, $return_as_object); } } diff --git a/core/modules/comment/src/Plugin/views/field/CommentedEntityLabel.php b/core/modules/comment/src/Plugin/views/field/CommentedEntityLabel.php index 7133ee5..fca2efb 100644 --- a/core/modules/comment/src/Plugin/views/field/CommentedEntityLabel.php +++ b/core/modules/comment/src/Plugin/views/field/CommentedEntityLabel.php @@ -97,7 +97,7 @@ public function query() { */ public function render(ResultRow $values) { /** @var \Drupal\comment\CommentInterface $comment */ - if(($comment = $values->_entity) && isset($this->loadedCommentedEntities[$comment->getCommentedEntityTypeId()]) && isset($this->loadedCommentedEntities[$comment->getCommentedEntityTypeId()][$comment->getCommentedEntityId()])) { + if(($comment = $this->getEntity($values)) && isset($this->loadedCommentedEntities[$comment->getCommentedEntityTypeId()]) && isset($this->loadedCommentedEntities[$comment->getCommentedEntityTypeId()][$comment->getCommentedEntityId()])) { /** @var $entity \Drupal\Core\Entity\EntityInterface */ $entity = $this->loadedCommentedEntities[$comment->getCommentedEntityTypeId()][$comment->getCommentedEntityId()]; @@ -106,8 +106,9 @@ public function render(ResultRow $values) { $this->options['alter']['make_link'] = TRUE; $this->options['alter']['url'] = $entity->urlInfo(); } - - return $this->sanitizeValue($entity->label()); + if ($entity->access('view')) { + return $this->sanitizeValue($entity->label()); + } } return ''; } @@ -119,11 +120,10 @@ public function preRender(&$values) { parent::preRender($values); $entity_ids_per_type = array(); - /** @var \Drupal\views\ResultRow $value */ foreach ($values as $value) { - /** @var \Drupal\comment\CommentInterface $entity */ - if ($entity = $value->_entity) { - $entity_ids_per_type[$entity->getCommentedEntityTypeId()][] = $entity->getCommentedEntityId(); + /** @var \Drupal\comment\CommentInterface $comment */ + if ($comment = $this->getEntity($value)) { + $entity_ids_per_type[$comment->getCommentedEntityTypeId()][] = $comment->getCommentedEntityId(); } } diff --git a/core/modules/comment/src/Tests/Views/CommentAdminTest.php b/core/modules/comment/src/Tests/Views/CommentAdminTest.php new file mode 100644 index 0000000..1946688 --- /dev/null +++ b/core/modules/comment/src/Tests/Views/CommentAdminTest.php @@ -0,0 +1,129 @@ +install(['views']); + $view = Views::getView('comment'); + $view->storage->enable()->save(); + \Drupal::service('router.builder')->rebuildIfNeeded(); + // Set anonymous comments to require approval. + user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array( + 'access comments' => TRUE, + 'post comments' => TRUE, + 'skip comment approval' => FALSE, + )); + $this->drupalLogin($this->adminUser); + // Ensure that doesn't require contact info. + $this->setCommentAnonymous('0'); + + // Test that the comments page loads correctly when there are no comments + $this->drupalGet('admin/content/comment'); + $this->assertText(t('No comments available.')); + + $this->drupalLogout(); + + // Post anonymous comment without contact info. + $subject = $this->randomMachineName(); + $body = $this->randomMachineName(); + // Set $contact to true so that it won't check for id and message. + $this->postComment($this->node, $body, $subject, TRUE); + $this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), 'Comment requires approval.'); + + // Get unapproved comment id. + $this->drupalLogin($this->adminUser); + $anonymous_comment4 = $this->getUnapprovedComment($subject); + $anonymous_comment4 = entity_create('comment', array( + 'cid' => $anonymous_comment4, + 'subject' => $subject, + 'comment_body' => $body, + 'entity_id' => $this->node->id(), + 'entity_type' => 'node', + 'field_name' => 'comment' + )); + $this->drupalLogout(); + + $this->assertFalse($this->commentExists($anonymous_comment4), 'Anonymous comment was not published.'); + + // Approve comment. + $this->drupalLogin($this->adminUser); + $edit = array(); + $edit['action'] = 'comment_publish_action'; + $edit['comment_bulk_form[0]'] = $anonymous_comment4->language()->getId() . '-' . $anonymous_comment4->id() . '-'; + $this->drupalPostForm('admin/content/comment/approval', $edit, t('Apply')); + + $this->assertText('Publish comment was applied to 1 item.', format_string('Operation "@operation" was performed on comment.', array('@operation' => 'publish'))); + $this->drupalLogout(); + + $this->drupalGet('node/' . $this->node->id()); + $this->assertTrue($this->commentExists($anonymous_comment4), 'Anonymous comment visible.'); + + // Post 2 anonymous comments without contact info. + $comments[] = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), TRUE); + $comments[] = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), TRUE); + + // Publish multiple comments in one operation. + $this->drupalLogin($this->adminUser); + $this->drupalGet('admin/content/comment/approval'); + $this->assertText(t('Unapproved comments (@count)', array('@count' => 2)), 'Two unapproved comments waiting for approval.'); + $edit = array( + "action" => 'comment_publish_action', + "comment_bulk_form[1]" => $comments[0]->language()->getId() . '-' . $comments[0]->id() . '-', + "comment_bulk_form[0]" => $comments[1]->language()->getId() . '-' . $comments[1]->id() . '-', + ); + $this->drupalPostForm(NULL, $edit, t('Apply')); + $this->assertText(t('Unapproved comments (@count)', array('@count' => 0)), 'All comments were approved.'); + + // Test message when no comments selected. + $this->drupalPostForm('admin/content/comment', [], t('Apply')); + $this->assertText(t('No comments selected.')); + // Delete multiple comments in one operation. + $edit = array( + 'action' => 'comment_delete_action', + "comment_bulk_form[1]" => $comments[0]->language()->getId() . '-' . $comments[0]->id() . '-', + "comment_bulk_form[0]" => $comments[1]->language()->getId() . '-' . $comments[1]->id() . '-', + "comment_bulk_form[2]" => $anonymous_comment4->language()->getId() . '-' . $anonymous_comment4->id() . '-', + ); + $this->drupalPostForm(NULL, $edit, t('Apply')); + $this->assertText(t('Are you sure you want to delete these comments and all their children?'), 'Confirmation required.'); + $this->drupalPostForm(NULL, [], t('Delete')); + $this->assertText(t('No comments available.'), 'All comments were deleted.'); + + // Make sure the label of unpublished node is not visible on listing page. + $this->drupalGet('admin/content/comment'); + $this->postComment($this->node, $this->randomMachineName()); + $this->drupalLogout(); + $this->commentAdminUser = $this->drupalCreateUser(array( + 'administer comments', + )); + $this->drupalLogin($this->commentAdminUser); + $this->drupalGet('admin/content/comment'); + $this->assertText(SafeMarkup::checkPlain($this->node->label()), 'Comment admin can see title of publish node'); + $this->node->setPublished(FALSE)->save(); + $this->assertFalse($this->node->isPublished(), 'Node is unpublished now.'); + drupal_flush_all_caches(); + $this->drupalGet('admin/content/comment'); + $this->assertNoText(SafeMarkup::checkPlain($this->node->label()), 'Comment admin cannot see title of unpublish node'); + } + +} diff --git a/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php b/core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php similarity index 76% copy from core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php copy to core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php index 84bf0a0..5821274 100644 --- a/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php +++ b/core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php @@ -2,20 +2,20 @@ /** * @file - * Contains \Drupal\Tests\node\Unit\Plugin\views\field\NodeBulkFormTest. + * Contains \Drupal\Tests\comment\Unit\Plugin\views\field\CommentBulkFormTest. */ -namespace Drupal\Tests\node\Unit\Plugin\views\field; +namespace Drupal\Tests\comment\Unit\Plugin\views\field; use Drupal\Core\DependencyInjection\ContainerBuilder; -use Drupal\node\Plugin\views\field\NodeBulkForm; +use Drupal\comment\Plugin\views\field\CommentBulkForm; use Drupal\Tests\UnitTestCase; /** - * @coversDefaultClass \Drupal\node\Plugin\views\field\NodeBulkForm - * @group node + * @coversDefaultClass \Drupal\comment\Plugin\views\field\CommentBulkForm + * @group comment */ -class NodeBulkFormTest extends UnitTestCase { +class CommentBulkFormTest extends UnitTestCase { /** * {@inheritdoc} @@ -36,7 +36,7 @@ public function testConstructor() { $action = $this->getMock('\Drupal\system\ActionConfigEntityInterface'); $action->expects($this->any()) ->method('getType') - ->will($this->returnValue('node')); + ->will($this->returnValue('comment')); $actions[$i] = $action; } @@ -62,8 +62,8 @@ public function testConstructor() { ->getMock(); $views_data->expects($this->any()) ->method('get') - ->with('node') - ->will($this->returnValue(array('table' => array('entity type' => 'node')))); + ->with('comment') + ->will($this->returnValue(array('table' => array('entity type' => 'comment')))); $container = new ContainerBuilder(); $container->set('views.views_data', $views_data); $container->set('string_translation', $this->getStringTranslationStub()); @@ -73,7 +73,7 @@ public function testConstructor() { $storage->expects($this->any()) ->method('get') ->with('base_table') - ->will($this->returnValue('node')); + ->will($this->returnValue('comment')); $executable = $this->getMockBuilder('Drupal\views\ViewExecutable') ->disableOriginalConstructor() @@ -87,11 +87,10 @@ public function testConstructor() { $definition['title'] = ''; $options = array(); - $form_error = $this->getMock('Drupal\Core\Form\FormErrorInterface'); - $node_bulk_form = new NodeBulkForm(array(), 'node_bulk_form', $definition, $entity_manager, $form_error); - $node_bulk_form->init($executable, $display, $options); + $comment_bulk_form = new CommentBulkForm(array(), 'comment_bulk_form', $definition, $entity_manager); + $comment_bulk_form->init($executable, $display, $options); - $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $node_bulk_form); + $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $comment_bulk_form); } } diff --git a/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php b/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php index 84bf0a0..327ebc1 100644 --- a/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php +++ b/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php @@ -87,8 +87,7 @@ public function testConstructor() { $definition['title'] = ''; $options = array(); - $form_error = $this->getMock('Drupal\Core\Form\FormErrorInterface'); - $node_bulk_form = new NodeBulkForm(array(), 'node_bulk_form', $definition, $entity_manager, $form_error); + $node_bulk_form = new NodeBulkForm(array(), 'node_bulk_form', $definition, $entity_manager); $node_bulk_form->init($executable, $display, $options); $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $node_bulk_form); diff --git a/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php b/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php index 1841b9b..0eefa5a 100644 --- a/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php +++ b/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php @@ -87,8 +87,7 @@ public function testConstructor() { $definition['title'] = ''; $options = array(); - $form_error = $this->getMock('Drupal\Core\Form\FormErrorInterface'); - $user_bulk_form = new UserBulkForm(array(), 'user_bulk_form', $definition, $entity_manager, $form_error); + $user_bulk_form = new UserBulkForm(array(), 'user_bulk_form', $definition, $entity_manager); $user_bulk_form->init($executable, $display, $options); $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $user_bulk_form);