diff --git a/core/modules/image/src/Tests/ImageThemeFunctionTest.php b/core/modules/image/src/Tests/ImageThemeFunctionTest.php index bb19c8a..9da2893 100644 --- a/core/modules/image/src/Tests/ImageThemeFunctionTest.php +++ b/core/modules/image/src/Tests/ImageThemeFunctionTest.php @@ -173,8 +173,8 @@ function testImageAltFunctionality() { ); $this->drupalSetContent(drupal_render($image_with_alt_working)); - $elements = $this->xpath('//img[@class="image-with-regular-alt"]'); - $this->assertEqual($this->getImageAlt($elements), 'Regular alt', 'Regular alt displays correctly'); + $elements = $this->xpath('//img[contains(@class, class) and contains(@alt, :alt)]', array(":class" => "image-with-regular-alt", ":alt" => "Regular alt")); + $this->assertEqual(count($elements), 1, 'Regular alt displays correctly'); $image_with_alt_attribute_not_working = array( '#theme' => 'image', @@ -190,18 +190,7 @@ function testImageAltFunctionality() { ); $this->drupalSetContent(drupal_render($image_with_alt_attribute_not_working)); - $elements = $this->xpath('//img[@class="image-with-attribute-alt"]'); - $this->assertEqual($this->getImageAlt($elements), 'Attribute alt', 'Attribute alt displays correctly'); - } - - /** - * Fetch the alt attribute of the first element - * - * @param SimpleXMLElement[] $xml_elements - * @return string - */ - protected function getImageAlt($xml_elements) { - $element = current($xml_elements); - return (string) $element->attributes()->alt; + $elements = $this->xpath('//img[contains(@class, class) and contains(@alt, :alt)]', array(":class" => "image-with-attribute-alt", ":alt" => "Attribute alt")); + $this->assertEqual(count($elements), 1, 'Attribute alt displays correctly'); } }