<?php
namespace Drupal\node\Tests;
class NodeRSSContentTest extends NodeTestBase {
public static $modules = array(
'node_test',
'views',
);
public static function getInfo() {
return array(
'name' => 'Node RSS Content',
'description' => 'Ensure that data added to nodes by other modules appears in RSS feeds.',
'group' => 'Node',
);
}
function setUp() {
parent::setUp();
$user = $this
->drupalCreateUser(array(
'bypass node access',
'access content',
'create article content',
));
$this
->drupalLogin($user);
}
function testNodeRSSContent() {
$node = $this
->drupalCreateNode(array(
'type' => 'article',
'promote' => 1,
));
$this
->drupalGet('rss.xml');
$rss_only_content = t('Extra data that should appear only in the RSS feed for node !nid.', array(
'!nid' => $node->nid,
));
$this
->assertText($rss_only_content, 'Node content designated for RSS appear in RSS feed.');
$non_rss_content = t('Extra data that should appear everywhere except the RSS feed for node !nid.', array(
'!nid' => $node->nid,
));
$this
->assertNoText($non_rss_content, 'Node content not designed for RSS does not appear in RSS feed.');
$test_element = array(
'key' => 'testElement',
'value' => t('Value of testElement RSS element for node !nid.', array(
'!nid' => $node->nid,
)),
);
$test_ns = 'xmlns:drupaltest="http://example.com/test-namespace"';
$this
->assertRaw(format_xml_elements(array(
$test_element,
)), 'Extra RSS elements appear in RSS feed.');
$this
->assertRaw($test_ns, 'Extra namespaces appear in RSS feed.');
$this
->drupalGet("node/{$node->nid}");
$this
->assertNoText($rss_only_content, 'Node content designed for RSS does not appear when viewing node.');
}
}