Commit a7d11509 authored by catch's avatar catch
Browse files

Issue #1821612 by dawehner, larowlan: Fixed Views comment RSS plugin calls...

Issue #1821612 by dawehner, larowlan: Fixed Views comment RSS plugin calls comment_view() with wrong arguments.
parent bc93618d
......@@ -65,10 +65,8 @@ function pre_render($result) {
$this->comments = comment_load_multiple($cids);
foreach ($this->comments as &$comment) {
$comment->depth = count(explode('.', $comment->thread)) - 1;
$nids[] = $comment->nid;
}
$this->nodes = node_load_multiple($nids);
}
/**
......@@ -106,7 +104,7 @@ function render($row) {
// Load the specified comment and its associated node:
$comment = $this->comments[$cid];
if (empty($comment) || empty($this->nodes[$comment->nid])) {
if (empty($comment)) {
return;
}
......@@ -133,7 +131,7 @@ function render($row) {
// The comment gets built and modules add to or modify
// $comment->rss_elements and $comment->rss_namespaces.
$build = comment_view($comment, $this->nodes[$comment->nid], 'rss');
$build = comment_view($comment, 'rss');
unset($build['#theme']);
if (!empty($comment->rss_namespaces)) {
......@@ -151,7 +149,7 @@ function render($row) {
$item_text .= drupal_render($build);
}
$item = new stdClass();
$item = new \stdClass();
$item->description = $item_text;
$item->title = $comment->label();
$item->link = $comment->link;
......
......@@ -22,6 +22,13 @@ abstract class CommentTestBase extends ViewTestBase {
*/
public static $modules = array('comment', 'comment_test_views');
/**
* Stores a comment used by the tests.
*
* @var \Drupal\comment\Plugin\Core\Entity\Comment
*/
public $comment;
function setUp() {
parent::setUp();
......@@ -42,7 +49,8 @@ function setUp() {
'cid' => '',
'pid' => '',
);
entity_create('comment', $comment)->save();
$this->comment = entity_create('comment', $comment);
$this->comment->save();
}
}
<?php
/**
* @file
* Contains \Drupal\comment\Tests\Views\RowRssTest.
*/
namespace Drupal\comment\Tests\Views;
/**
* Tests the comment rss row plugin.
*
* @see \Drupal\comment\Plugin\views\row\Rss
*/
class RowRssTest extends CommentTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_comment_rss');
public static function getInfo() {
return array(
'name' => 'Comment: Rss Row',
'description' => 'Tests the comment rss row plugin.',
'group' => 'Views Modules',
);
}
/**
* Test comment rss output.
*/
public function testRssRow() {
$this->drupalGet('test-comment-rss');
$result = $this->xpath('//item');
$this->assertEqual(count($result), 1, 'Just one comment was found in the rss output.');
$this->assertEqual($result[0]->pubdate, gmdate('r', $this->comment->created), 'The right pubDate appears in the rss output.');
}
}
api_version: '3.0'
base_field: cid
base_table: comment
core: 8.x
description: ''
disabled: '0'
display:
default:
display_plugin: default
id: default
display_title: Master
position: ''
display_options:
access:
type: perm
cache:
type: none
query:
type: views_query
exposed_form:
type: basic
pager:
type: full
style:
type: default
row:
type: fields
relationships:
nid:
id: nid
table: comment
field: nid
required: '1'
fields:
subject:
id: subject
table: comment
field: subject
label: ''
alter:
alter_text: '0'
make_link: '0'
absolute: '0'
trim: '0'
word_boundary: '0'
ellipsis: '0'
strip_tags: '0'
html: '0'
hide_empty: '0'
empty_zero: '0'
link_to_comment: '1'
filters: { }
sorts: { }
feed_1:
display_plugin: feed
id: feed_1
display_title: Feed
position: ''
display_options:
path: test-comment-rss
human_name: test_comment_rss
module: views
name: test_comment_rss
tag: ''
uuid: 9b1b1e58-d41b-468a-9d04-4e6bde742c29
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment