Chris@0: drupalCreateUser(['bypass node access', 'access content', 'create article content']); Chris@0: $this->drupalLogin($user); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Ensures that a new node includes the custom data when added to an RSS feed. Chris@0: */ Chris@0: public function testNodeRSSContent() { Chris@0: // Create a node. Chris@0: $node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]); Chris@0: Chris@0: $this->drupalGet('rss.xml'); Chris@0: Chris@0: // Check that content added in 'rss' view mode appear in RSS feed. Chris@0: $rss_only_content = t('Extra data that should appear only in the RSS feed for node @nid.', ['@nid' => $node->id()]); Chris@0: $this->assertText($rss_only_content, 'Node content designated for RSS appear in RSS feed.'); Chris@0: Chris@0: // Check that content added in view modes other than 'rss' doesn't Chris@0: // appear in RSS feed. Chris@0: $non_rss_content = t('Extra data that should appear everywhere except the RSS feed for node @nid.', ['@nid' => $node->id()]); Chris@0: $this->assertNoText($non_rss_content, 'Node content not designed for RSS does not appear in RSS feed.'); Chris@0: Chris@0: // Check that extra RSS elements and namespaces are added to RSS feed. Chris@0: $test_element = '' . t('Value of testElement RSS element for node @nid.', ['@nid' => $node->id()]) . ''; Chris@0: $test_ns = 'xmlns:drupaltest="http://example.com/test-namespace"'; Chris@0: $this->assertRaw($test_element, 'Extra RSS elements appear in RSS feed.'); Chris@0: $this->assertRaw($test_ns, 'Extra namespaces appear in RSS feed.'); Chris@0: Chris@0: // Check that content added in 'rss' view mode doesn't appear when Chris@0: // viewing node. Chris@0: $this->drupalGet('node/' . $node->id()); Chris@0: $this->assertNoText($rss_only_content, 'Node content designed for RSS does not appear when viewing node.'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests relative, root-relative, protocol-relative and absolute URLs. Chris@0: */ Chris@0: public function testUrlHandling() { Chris@0: // Only the plain_text text format is available by default, which escapes Chris@0: // all HTML. Chris@0: FilterFormat::create([ Chris@0: 'format' => 'full_html', Chris@0: 'name' => 'Full HTML', Chris@0: 'filters' => [], Chris@0: ])->save(); Chris@0: Chris@0: $defaults = [ Chris@0: 'type' => 'article', Chris@0: 'promote' => 1, Chris@0: ]; Chris@0: $this->drupalCreateNode($defaults + [ Chris@0: 'body' => [ Chris@0: 'value' => '

Root-relative URL

', Chris@0: 'format' => 'full_html', Chris@0: ], Chris@0: ]); Chris@0: $protocol_relative_url = substr(file_create_url('public://protocol-relative'), strlen(\Drupal::request()->getScheme() . ':')); Chris@0: $this->drupalCreateNode($defaults + [ Chris@0: 'body' => [ Chris@0: 'value' => '

Protocol-relative URL

', Chris@0: 'format' => 'full_html', Chris@0: ], Chris@0: ]); Chris@0: $absolute_url = file_create_url('public://absolute'); Chris@0: $this->drupalCreateNode($defaults + [ Chris@0: 'body' => [ Chris@0: 'value' => '

Absolute URL

', Chris@0: 'format' => 'full_html', Chris@0: ], Chris@0: ]); Chris@0: Chris@0: $this->drupalGet('rss.xml'); Chris@0: $this->assertRaw(file_create_url('public://root-relative'), 'Root-relative URL is transformed to absolute.'); Chris@0: $this->assertRaw($protocol_relative_url, 'Protocol-relative URL is left untouched.'); Chris@0: $this->assertRaw($absolute_url, 'Absolute URL is left untouched.'); Chris@0: } Chris@0: Chris@0: }