You are here

public function ImageAdminStylesTest::testFlushUserInterface in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/image/src/Tests/ImageAdminStylesTest.php \Drupal\image\Tests\ImageAdminStylesTest::testFlushUserInterface()

Test flush user interface.

File

core/modules/image/src/Tests/ImageAdminStylesTest.php, line 385
Contains \Drupal\image\Tests\ImageAdminStylesTest.

Class

ImageAdminStylesTest
Tests creation, deletion, and editing of image styles and effects.

Namespace

Drupal\image\Tests

Code

public function testFlushUserInterface() {
  $admin_path = 'admin/config/media/image-styles';

  // Create a new style.
  $style_name = strtolower($this
    ->randomMachineName(10));
  $style = entity_create('image_style', array(
    'name' => $style_name,
    'label' => $this
      ->randomString(),
  ));
  $style
    ->save();

  // Create an image to make sure it gets flushed.
  $files = $this
    ->drupalGetTestFiles('image');
  $image_uri = $files[0]->uri;
  $derivative_uri = $style
    ->buildUri($image_uri);
  $this
    ->assertTrue($style
    ->createDerivative($image_uri, $derivative_uri));
  $this
    ->assertEqual($this
    ->getImageCount($style), 1);

  // Go to image styles list page and check if the flush operation link
  // exists.
  $this
    ->drupalGet($admin_path);
  $flush_path = $admin_path . '/manage/' . $style_name . '/flush';
  $this
    ->assertLinkByHref($flush_path);

  // Flush the image style derivatives using the user interface.
  $this
    ->drupalPostForm($flush_path, array(), t('Flush'));

  // The derivative image file should have been deleted.
  $this
    ->assertEqual($this
    ->getImageCount($style), 0);
}