function ImageAdminStylesTest::testEditEffect in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/image/src/Tests/ImageAdminStylesTest.php \Drupal\image\Tests\ImageAdminStylesTest::testEditEffect()
Verifies that editing an image effect does not cause it to be duplicated.
File
- core/
modules/ image/ src/ Tests/ ImageAdminStylesTest.php, line 343 - Contains \Drupal\image\Tests\ImageAdminStylesTest.
Class
- ImageAdminStylesTest
- Tests creation, deletion, and editing of image styles and effects.
Namespace
Drupal\image\TestsCode
function testEditEffect() {
// Add a scale effect.
$style_name = 'test_style_effect_edit';
$this
->drupalGet('admin/config/media/image-styles/add');
$this
->drupalPostForm(NULL, array(
'label' => 'Test style effect edit',
'name' => $style_name,
), t('Create new style'));
$this
->drupalPostForm(NULL, array(
'new' => 'image_scale_and_crop',
), t('Add'));
$this
->drupalPostForm(NULL, array(
'data[width]' => '300',
'data[height]' => '200',
), t('Add effect'));
$this
->assertText(t('Scale and crop 300×200'));
// There should normally be only one edit link on this page initially.
$this
->clickLink(t('Edit'));
$this
->drupalPostForm(NULL, array(
'data[width]' => '360',
'data[height]' => '240',
), t('Update effect'));
$this
->assertText(t('Scale and crop 360×240'));
// Check that the previous effect is replaced.
$this
->assertNoText(t('Scale and crop 300×200'));
// Add another scale effect.
$this
->drupalGet('admin/config/media/image-styles/add');
$this
->drupalPostForm(NULL, array(
'label' => 'Test style scale edit scale',
'name' => 'test_style_scale_edit_scale',
), t('Create new style'));
$this
->drupalPostForm(NULL, array(
'new' => 'image_scale',
), t('Add'));
$this
->drupalPostForm(NULL, array(
'data[width]' => '12',
'data[height]' => '19',
), t('Add effect'));
// Edit the scale effect that was just added.
$this
->clickLink(t('Edit'));
$this
->drupalPostForm(NULL, array(
'data[width]' => '24',
'data[height]' => '19',
), t('Update effect'));
$this
->drupalPostForm(NULL, array(
'new' => 'image_scale',
), t('Add'));
// Add another scale effect and make sure both exist.
$this
->drupalPostForm(NULL, array(
'data[width]' => '12',
'data[height]' => '19',
), t('Add effect'));
$this
->assertText(t('Scale 24×19'));
$this
->assertText(t('Scale 12×19'));
// Try to edit a nonexistent effect.
$uuid = $this->container
->get('uuid');
$this
->drupalGet('admin/config/media/image-styles/manage/' . $style_name . '/effects/' . $uuid
->generate());
$this
->assertResponse(404);
}