You are here

public function XMLAttributeTest::testXmlAttribute in GraphQL 8.4

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

File

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

Class

XMLAttributeTest
Data producers XMLAttribute test class.

Namespace

Drupal\Tests\graphql\Kernel\DataProducer\XML

Code

public function testXmlAttribute() : void {
  $document = $this
    ->loadDocument();
  $xpath = new \DOMXPath($document->ownerDocument);
  $div = iterator_to_array($xpath
    ->query('//div/div', $document));
  $h1 = iterator_to_array($xpath
    ->query('//div/h1', $document));
  $this
    ->assertEquals('some_header', $this
    ->executeDataProducer('xml_attribute', [
    'dom' => $h1[0],
    'name' => 'data-tag-type',
  ]));
  $this
    ->assertEquals('', $this
    ->executeDataProducer('xml_attribute', [
    'dom' => $h1[0],
    'name' => 'no-attribute',
  ]));
  $this
    ->assertEquals('content', $this
    ->executeDataProducer('xml_attribute', [
    'dom' => $div[0],
    'name' => 'class',
  ]));
}