public function ImageAdminStylesTest::testEditEffect in Drupal 8
Same name and namespace in other branches
- 9 core/modules/image/tests/src/Functional/ImageAdminStylesTest.php \Drupal\Tests\image\Functional\ImageAdminStylesTest::testEditEffect()
Verifies that editing an image effect does not cause it to be duplicated.
File
- core/
modules/ image/ tests/ src/ Functional/ ImageAdminStylesTest.php, line 374
Class
- ImageAdminStylesTest
- Tests creation, deletion, and editing of image styles and effects.
Namespace
Drupal\Tests\image\FunctionalCode
public function testEditEffect() {
// Add a scale effect.
$style_name = 'test_style_effect_edit';
$this
->drupalGet('admin/config/media/image-styles/add');
$this
->drupalPostForm(NULL, [
'label' => 'Test style effect edit',
'name' => $style_name,
], t('Create new style'));
$this
->drupalPostForm(NULL, [
'new' => 'image_scale_and_crop',
], t('Add'));
$this
->drupalPostForm(NULL, [
'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, [
'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, [
'label' => 'Test style scale edit scale',
'name' => 'test_style_scale_edit_scale',
], t('Create new style'));
$this
->drupalPostForm(NULL, [
'new' => 'image_scale',
], t('Add'));
$this
->drupalPostForm(NULL, [
'data[width]' => '12',
'data[height]' => '19',
], t('Add effect'));
// Edit the scale effect that was just added.
$this
->clickLink(t('Edit'));
$this
->drupalPostForm(NULL, [
'data[width]' => '24',
'data[height]' => '19',
], t('Update effect'));
// Add another scale effect and make sure both exist. Click through from
// the overview to make sure that it is possible to add new effect then.
$this
->drupalGet('admin/config/media/image-styles');
$rows = $this
->xpath('//table/tbody/tr');
$i = 0;
foreach ($rows as $row) {
if ($row
->find('css', 'td')
->getText() === 'Test style scale edit scale') {
$this
->clickLink('Edit', $i);
break;
}
$i++;
}
$this
->drupalPostForm(NULL, [
'new' => 'image_scale',
], t('Add'));
$this
->drupalPostForm(NULL, [
'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
->assertSession()
->statusCodeEquals(404);
}