XMLContentTest.php in GraphQL 8.4
File
tests/src/Kernel/DataProducer/XML/XMLContentTest.php
View source
<?php
namespace Drupal\Tests\graphql\Kernel\DataProducer\XML;
class XMLContentTest extends XMLTestBase {
public function testXmlContent() : void {
$document = $this
->loadDocument();
$xpath = new \DOMXPath($document->ownerDocument);
$h1 = iterator_to_array($xpath
->query('//div/h1', $document));
$span = iterator_to_array($xpath
->query('//div/div/span', $document));
$this
->assertEquals('Header', $this
->executeDataProducer('xml_content', [
'dom' => $h1[0],
]));
$content = '<p>This is one paragraph.</p><p>This is a second paragraph.</p>';
$this
->assertEquals($content, $this
->executeDataProducer('xml_content', [
'dom' => $span[0],
]));
}
}