You are here

public function XMLContentTest::testXmlContent in GraphQL 8.4

@covers \Drupal\graphql\Plugin\GraphQL\DataProducer\XML\XMLContent::resolve

File

tests/src/Kernel/DataProducer/XML/XMLContentTest.php, line 15

Class

XMLContentTest
Data producers XMLContent test class.

Namespace

Drupal\Tests\graphql\Kernel\DataProducer\XML

Code

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],
  ]));
}