public static function PHPUnit_Framework_Assert::assertEqualXMLStructure

Asserts that a hierarchy of DOMElements matches.

@author Mattis Stordalen Flister <mattis@xait.no> @since Method available since Release 3.3.0

Parameters

DOMElement $expectedElement:

DOMElement $actualElement:

boolean $checkAttributes:

string $message:

6 calls to PHPUnit_Framework_Assert::assertEqualXMLStructure()
Framework_AssertTest::testXMLStructureAttributesAreSameButValuesAreNot in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertEqualXMLStructure
Framework_AssertTest::testXMLStructureIgnoreTextNodes in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertEqualXMLStructure
Framework_AssertTest::testXMLStructureIsSame in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertEqualXMLStructure
Framework_AssertTest::testXMLStructureIsSameButDataIsNot in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertEqualXMLStructure
Framework_AssertTest::testXMLStructureWrongNumberOfAttributes in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertEqualXMLStructure @expectedException PHPUnit_Framework_ExpectationFailedException

... See full list

File

drupal/core/vendor/phpunit/phpunit/PHPUnit/Framework/Assert.php, line 1774

Class

PHPUnit_Framework_Assert
A set of assert methods.

Code

public static function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, $checkAttributes = FALSE, $message = '') {
  self::assertEquals($expectedElement->tagName, $actualElement->tagName, $message);
  if ($checkAttributes) {
    self::assertEquals($expectedElement->attributes->length, $actualElement->attributes->length, sprintf('%s%sNumber of attributes on node "%s" does not match', $message, !empty($message) ? "\n" : '', $expectedElement->tagName));
    for ($i = 0; $i < $expectedElement->attributes->length; $i++) {
      $expectedAttribute = $expectedElement->attributes
        ->item($i);
      $actualAttribute = $actualElement->attributes
        ->getNamedItem($expectedAttribute->name);
      if (!$actualAttribute) {
        self::fail(sprintf('%s%sCould not find attribute "%s" on node "%s"', $message, !empty($message) ? "\n" : '', $expectedAttribute->name, $expectedElement->tagName));
      }
    }
  }
  PHPUnit_Util_XML::removeCharacterDataNodes($expectedElement);
  PHPUnit_Util_XML::removeCharacterDataNodes($actualElement);
  self::assertEquals($expectedElement->childNodes->length, $actualElement->childNodes->length, sprintf('%s%sNumber of child nodes of "%s" differs', $message, !empty($message) ? "\n" : '', $expectedElement->tagName));
  for ($i = 0; $i < $expectedElement->childNodes->length; $i++) {
    self::assertEqualXMLStructure($expectedElement->childNodes
      ->item($i), $actualElement->childNodes
      ->item($i), $checkAttributes, $message);
  }
}