commit b658ec1e356aa94fa3be23660ece1e4b13f15262 Author: Shane Auckland Date: Wed Apr 17 18:36:33 2013 +0100 1898420-new_changes diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc index 4da6e41..cb6a4ef 100644 --- a/core/modules/image/image.field.inc +++ b/core/modules/image/image.field.inc @@ -452,6 +452,7 @@ function template_preprocess_image_widget(&$variables) { * - item: the formatter item */ function template_preprocess_image_formatter(&$variables) { + file_put_contents('formatter.txt',print_r($variables['item'],true), FILE_APPEND); $item = $variables['item']; // Build a render array for the image from the formatter item. diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php index 1d1c79d..8ec039a 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php @@ -32,68 +32,6 @@ public static function getInfo() { } /** - * Constructs an xpath query string - * - * @param string $name - * Name of the element to search for - * @param array $attributes - * List of attributes the element must contain - * - * @return string - * Xpath expression - */ - protected function buildXPath($name, array $attributes) { - $expression = '/' . $name . '['; - $attribs = ''; - foreach ($attributes as $attr => $value) { - $attribs .= ' and @' . $attr . '=\'' . $value . '\''; - } - $expression .= substr($attribs,5) . ']'; - return $expression; - } - - /** - * Compare a string of HTML to an element definition. - * - * An element can be defined by its name and attributes. This compares a - * provided string of HTML containing a target element with an XPath - * expression constructed from the expected name and attributes. Comparison - * fails if the XPath expression does not match an element, or if it matches - * an element that contains unexpected attributes. Example: - * @code - * $this->compareElement($rawHtml, 'img', array( - * 'src' => 'some-uri.jpg', - * 'width => 50, - * 'alt' => '', - * ); - * @endcode - * - * @param string $element - * Raw HTML to search for an element. - * @param string $name - * The name of the element to match. - * @param array $attributes - * Array of expected attributes. - */ - protected function compareElement($element, $name, array $attributes) { - $expression = $this->buildXPath($name, $attributes); - - $xml = new \SimpleXMLElement($element); - $found = $xml->xpath($expression); - $number_of_elements = count($found); - // Assert that the xpath matches an element - $this->assertEqual($number_of_elements, 1, htmlentities($element) . " matches the expected expression: $expression."); - if ($number_of_elements) { - // Assert that the matched element doesn't contain unexpected attributes. - foreach ($found[0]->attributes as $attribute => $value) { - if (!array_key_exists($attribute, $attributes)) { - $this->fail("Unexpected attribute $attribute found."); - } - } - } - } - - /** * Test styled image dimensions cumulatively. */ function testImageDimensions() { @@ -132,13 +70,7 @@ function testImageDimensions() { image_effect_save($style, $effect); $img_tag = theme('image_style', $variables); - $this->compareElement($img_tag, 'img', array( - 'class' => 'image-style-test', - 'src' => $url, - 'width' => 120, - 'height' => 60, - 'alt' => '' - )); + $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); $this->assertResponse(200, 'Image was generated at the URL.'); @@ -159,13 +91,7 @@ function testImageDimensions() { image_effect_save($style, $effect); $img_tag = theme('image_style', $variables); - $this->compareElement($img_tag, 'img', array( - 'class' => 'image-style-test', - 'src' => $url, - 'width' => 60, - 'height' => 120, - 'alt' => '' - )); + $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); $this->assertResponse(200, 'Image was generated at the URL.'); @@ -187,13 +113,7 @@ function testImageDimensions() { image_effect_save($style, $effect); $img_tag = theme('image_style', $variables); - $this->compareElement($img_tag, 'img', array( - 'class' => 'image-style-test', - 'src' => $url, - 'width' => 45, - 'height' => 90, - 'alt' => '' - )); + $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); $this->assertResponse(200, 'Image was generated at the URL.'); @@ -215,13 +135,7 @@ function testImageDimensions() { image_effect_save($style, $effect); $img_tag = theme('image_style', $variables); - $this->compareElement($img_tag, 'img', array( - 'class' => 'image-style-test', - 'src' => $url, - 'width' => 45, - 'height' => 90, - 'alt' => '' - )); + $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); $this->assertResponse(200, 'Image was generated at the URL.'); @@ -239,13 +153,7 @@ function testImageDimensions() { image_effect_save($style, $effect); $img_tag = theme('image_style', $variables); - $this->compareElement($img_tag, 'img', array( - 'class' => 'image-style-test', - 'src' => $url, - 'width' => 45, - 'height' => 90, - 'alt' => '' - )); + $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); $this->assertResponse(200, 'Image was generated at the URL.'); @@ -266,11 +174,7 @@ function testImageDimensions() { image_effect_save($style, $effect); $img_tag = theme('image_style', $variables); - $this->compareElement($img_tag, 'img', array( - 'class' => 'image-style-test', - 'src' => $url, - 'alt' => '' - )); + $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); $this->assertResponse(200, 'Image was generated at the URL.'); @@ -290,13 +194,7 @@ function testImageDimensions() { image_effect_save($style, $effect); $img_tag = theme('image_style', $variables); - $this->compareElement($img_tag, 'img', array( - 'class' => 'image-style-test', - 'src' => $url, - 'width' => 30, - 'height' => 30, - 'alt' => '' - )); + $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); $this->assertResponse(200, 'Image was generated at the URL.'); @@ -317,11 +215,7 @@ function testImageDimensions() { image_effect_save($style, $effect); $img_tag = theme('image_style', $variables); - $this->compareElement($img_tag, 'img', array( - 'class' => 'image-style-test', - 'src' => $url, - 'alt' => '' - )); + $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); $this->assertResponse(200, 'Image was generated at the URL.'); @@ -339,10 +233,6 @@ function testImageDimensions() { image_effect_save($style, $effect); $img_tag = theme('image_style', $variables); - $this->compareElement($img_tag, 'img', array( - 'class' => 'image-style-test', - 'src' => $url, - 'alt' => '' - )); + $this->assertEqual($img_tag, ''); } } diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php index cd00cb1..0d73884 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php @@ -57,7 +57,7 @@ function testImageFormatterTheme() { ), ); $rendered_element = render($element); - $expected_result = ''; + $expected_result = ''; $this->assertEqual($expected_result, $rendered_element, 'theme_image_formatter() correctly renders without title, alt, or path options.'); // Link the image to a fragment on the page, and not a full URL. @@ -68,7 +68,7 @@ function testImageFormatterTheme() { 'fragment' => $fragment, ); $rendered_element = render($element); - $expected_result = ''; + $expected_result = ''; $this->assertEqual($expected_result, $rendered_element, 'theme_image_formatter() correctly renders a link fragment.'); } @@ -93,7 +93,7 @@ function testImageStyleTheme() { '#uri' => $original_uri, ); $rendered_element = render($element); - $expected_result = ''; + $expected_result = ''; $this->assertEqual($expected_result, $rendered_element, 'theme_image_style() renders an image correctly.'); } diff --git a/core/modules/image/templates/image-formatter.html.twig b/core/modules/image/templates/image-formatter.html.twig index a78f0f4..7a5b278 100644 --- a/core/modules/image/templates/image-formatter.html.twig +++ b/core/modules/image/templates/image-formatter.html.twig @@ -15,8 +15,10 @@ * @ingroup themeable */ #} -{% if url %} - {{ image }} -{% else %} - {{ image }} -{% endif %} +{% spaceless %} + {% if url %} + {{ image }} + {% else %} + {{ image }} + {% endif %} +{% endspaceless %} diff --git a/core/modules/image/templates/image-style.html.twig b/core/modules/image/templates/image-style.html.twig index 546affb..13575cf 100644 --- a/core/modules/image/templates/image-style.html.twig +++ b/core/modules/image/templates/image-style.html.twig @@ -28,4 +28,4 @@ */ #} {# @todo Remove and consolidate with image: http://drupal.org/node/1804614 #} - +{% spaceless %}{% endspaceless %}