Ejemplo n.º 1
0
 /**
  * Checks identity of two DOM elements.
  *
  * @param Element $element
  * @param Element $other
  */
 public function assertElementEquals(Element $element, Element $other)
 {
     if (!$element->equals($other)) {
         $message = __FUNCTION__ . ': Element id=' . $element->getId() . ' (tag = "' . $element->name() . '"' . (($htmlId = $element->attribute('id')) !== '' ? ", html id=\"{$htmlId}\"" : '') . ')' . ' does not equal to element id=' . $other->getId() . ' (tag = "' . $other->name() . '"' . (($htmlId = $other->attribute('id')) !== '' ? ", html id=\"{$htmlId}\"" : '') . ')' . '.';
         $this->fail($message);
     } else {
         $this->assertTrue(TRUE);
     }
 }
Ejemplo n.º 2
0
 /**
  * Checks element name and attributes.
  *
  * @param Element $element Element to examine.
  * @param string $shortcutId Name of the shortcut (needed for the eventual error message).
  * @param string|NULL $expectedTagName Expected tag name.
  * @param array|NULL $expectedAttribs Expected values of attributes.
  * @throws ViewStateException
  */
 private function checkTagNameAndAttributes(Element $element, $shortcutId, $expectedTagName, $expectedAttribs)
 {
     $actualTagName = $element->name();
     if (isset($expectedTagName) && $actualTagName !== $expectedTagName) {
         throw new ViewStateException(__METHOD__ . ": Element '{$shortcutId}' is expected to be a tag '{$expectedTagName}', but is '{$actualTagName}'.");
     }
     if (isset($expectedAttribs) && is_array($expectedAttribs)) {
         foreach ($expectedAttribs as $attribName => $expectedValue) {
             $actualValue = $element->attribute($attribName);
             if ($actualValue !== $expectedValue) {
                 throw new ViewStateException(__METHOD__ . ": Expected value of '{$attribName}' is '{$expectedValue}' on element '{$shortcutId}', actual value is '{$actualValue}'.");
             }
         }
     }
 }