public function ImageAdminStylesTest::testFlushUserInterface in Drupal 9
Same name and namespace in other branches
- 8 core/modules/image/tests/src/Functional/ImageAdminStylesTest.php \Drupal\Tests\image\Functional\ImageAdminStylesTest::testFlushUserInterface()
Tests flush user interface.
File
- core/
modules/ image/ tests/ src/ Functional/ ImageAdminStylesTest.php, line 436
Class
- ImageAdminStylesTest
- Tests creation, deletion, and editing of image styles and effects.
Namespace
Drupal\Tests\image\FunctionalCode
public function testFlushUserInterface() {
$admin_path = 'admin/config/media/image-styles';
// Create a new style.
$style_name = strtolower($this
->randomMachineName(10));
$style = ImageStyle::create([
'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
->assertEquals(1, $this
->getImageCount($style));
// 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
->assertSession()
->linkByHrefExists($flush_path);
// Flush the image style derivatives using the user interface.
$this
->drupalGet($flush_path);
$this
->submitForm([], 'Flush');
// The derivative image file should have been deleted.
$this
->assertEquals(0, $this
->getImageCount($style));
}