function RssViewIntegrationTest::testRdfNamespacesAreAddedToRssViews

Tests that RSS views have RDF's XML namespaces defined.

File

core/modules/rdf/tests/src/Functional/RssViewIntegrationTest.php, line 30

Class

RssViewIntegrationTest
@group rdf @group legacy

Namespace

Drupal\Tests\rdf\Functional

Code

public function testRdfNamespacesAreAddedToRssViews() : void {
    // RDF's namespaces are only attached when there is content in the feed.
    $node_type = $this->drupalCreateContentType()
        ->id();
    $this->drupalCreateNode([
        'type' => $node_type,
    ]);
    $this->drupalGet('rdf-rss-test');
    $this->assertSession()
        ->statusCodeEquals(200);
    // Mink insists on treating the page as an HTML document, so we have to use
    // PHP's built-in DOM extension to examine the RSS feed.
    $xml = $this->getSession()
        ->getPage()
        ->getContent();
    $document = new \DOMDocument();
    $this->assertTrue($document->loadXML($xml));
    foreach (rdf_get_namespaces() as $prefix => $uri) {
        if ($prefix === 'dc') {
            continue;
        }
        $this->assertSame($uri, $document->lookupNamespaceURI($prefix));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.