XMLAttributeTest.php in GraphQL 8.4
File
tests/src/Kernel/DataProducer/XML/XMLAttributeTest.php
View source
<?php
namespace Drupal\Tests\graphql\Kernel\DataProducer\XML;
class XMLAttributeTest extends XMLTestBase {
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',
]));
}
}