diff --git a/core/modules/image/src/Tests/ImageFieldDisplayTest.php b/core/modules/image/src/Tests/ImageFieldDisplayTest.php index 34f5f94..2cf6026 100644 --- a/core/modules/image/src/Tests/ImageFieldDisplayTest.php +++ b/core/modules/image/src/Tests/ImageFieldDisplayTest.php @@ -10,7 +10,7 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\field\Entity\FieldStorageConfig; use Drupal\user\RoleInterface; -use Drupal\Core\File; +use Drupal\file\Entity\File; use Drupal\image\Entity\ImageStyle; /** @@ -126,7 +126,7 @@ function _testImageFieldFormatters($scheme) { $this->drupalGet('node/' . $nid); $file = File::load($node->{$field_name}->target_id); - $this->assertNoCacheTag($file->getCacheTags()[0], 'No image style cache tag found.'); + $this->assertCacheTag($file->getCacheTags()[0]); $this->assertRaw($default_output, 'Image linked to file formatter displaying correctly on full node view.'); // Verify that the image can be downloaded. $this->assertEqual(file_get_contents($test_image->uri), $this->drupalGet(file_create_url($image_uri)), 'File was downloaded successfully.'); @@ -156,8 +156,7 @@ function _testImageFieldFormatters($scheme) { '#height' => 20, ); $this->drupalGet('node/' . $nid); - $file = File::load($node->{$field_name}->target_id); - $this->assertNoCacheTag($file->getCacheTags()[0], 'No image style cache tag found.'); + $this->assertNoCacheTag($file->getCacheTags()[0]); $elements = $this->xpath( '//a[@href=:path]/img[@src=:url and @alt=:alt and @width=:width and @height=:height]', array( @@ -337,8 +336,8 @@ function testImageFieldDefaultImage() { // Verify that no image is displayed on the page by checking for the class // that would be used on the image field. $this->assertNoPattern('
', 'No image displayed when no image is attached and no default image specified.'); - $file = File::load($node->{$field_name}->target_id); - $this->assertNoCacheTag($file->getCacheTags()[0], 'No image style cache tag found.'); + $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags'); + $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.'); // Add a default image to the public image field. $images = $this->drupalGetTestFiles('image'); @@ -366,7 +365,7 @@ function testImageFieldDefaultImage() { ); $default_output = str_replace("\n", NULL, drupal_render($image)); $this->drupalGet('node/' . $node->id()); - $this->assertNoCacheTag($file->getCacheTags()[0], 'No image style cache tag found.'); + $this->assertNoCacheTag($file->getCacheTags()[0]); $this->assertRaw($default_output, 'Default image displayed when no user supplied image is present.'); // Create a node with an image attached and ensure that the default image @@ -388,7 +387,8 @@ function testImageFieldDefaultImage() { ); $image_output = str_replace("\n", NULL, drupal_render($image)); $this->drupalGet('node/' . $nid); - $this->assertNoCacheTag($file->getCacheTags()[0], 'No image style cache tag found.'); $this->assertNoRaw($default_output, 'Default image is not displayed when user supplied image is present.'); + $this->assertNoCacheTag($file->getCacheTags()[0]); + $this->assertNoRaw($default_output, 'Default image is not displayed when user supplied image is present.'); $this->assertRaw($image_output, 'User supplied image is displayed.'); // Remove default image from the field and make sure it is no longer used. @@ -433,7 +433,8 @@ function testImageFieldDefaultImage() { ); $default_output = str_replace("\n", NULL, drupal_render($image)); $this->drupalGet('node/' . $node->id()); - $this->assertNoCacheTag($file->getCacheTags()[0], 'No image style cache tag found.'); $this->assertRaw($default_output, 'Default private image displayed when no user supplied image is present.'); + $this->assertNoCacheTag($file->getCacheTags()[0]); + $this->assertRaw($default_output, 'Default private image displayed when no user supplied image is present.'); } }