You are here

public function Issue1472Test::testAssertEqualXMLStructure in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/tests/Regression/GitHub/1472/Issue1472Test.php \Issue1472Test::testAssertEqualXMLStructure()

File

vendor/phpunit/phpunit/tests/Regression/GitHub/1472/Issue1472Test.php, line 4

Class

Issue1472Test

Code

public function testAssertEqualXMLStructure() {
  $doc = new DOMDocument();
  $doc
    ->loadXML('<root><label>text content</label></root>');
  $xpath = new DOMXPath($doc);
  $labelElement = $doc
    ->getElementsByTagName('label')
    ->item(0);
  $this
    ->assertEquals(1, $xpath
    ->evaluate('count(//label[text() = "text content"])'));
  $expectedElmt = $doc
    ->createElement('label', 'text content');
  $this
    ->assertEqualXMLStructure($expectedElmt, $labelElement);

  // the following assertion fails, even though it passed before - which is due to the assertEqualXMLStructure() has modified the $labelElement
  $this
    ->assertEquals(1, $xpath
    ->evaluate('count(//label[text() = "text content"])'));
}