Commit 0d073ceb authored by webchick's avatar webchick

Issue #1821534 by andypost, xjm: Fixed Can't delete image effects from an image style.

parent 9fa17253
......@@ -1070,7 +1070,7 @@ function image_effect_save($style, &$effect) {
* An image effect array.
*/
function image_effect_delete($style, $effect) {
unset($style->effects['ieid']);
unset($style->effects[$effect['ieid']]);
$style->save();
image_style_flush($style);
}
......
......@@ -118,18 +118,31 @@ function testStyle() {
}
}
// Edit effect form.
// Revisit each form to make sure the effect was saved.
// Load the saved image style.
$style = entity_load('image_style', $style_name);
// Confirm that all effects on the image style have settings on the effect
// edit form that match what was saved.
$ieids = array();
foreach ($style->effects as $ieid => $effect) {
// Store the ieid for later use.
$ieids[$effect['name']] = $ieid;
$this->drupalGet($style_path . '/effects/' . $ieid);
foreach ($effect_edits[$effect['name']] as $field => $value) {
$this->assertFieldByName($field, $value, format_string('The %field field in the %effect effect has the correct value of %value.', array('%field' => $field, '%effect' => $effect['name'], '%value' => $value)));
}
}
// Assert that every effect was saved.
foreach (array_keys($effect_edits) as $effect_name) {
$this->assertTrue(isset($ieids[$effect_name]), format_string(
'A %effect_name effect was saved with ID %ieid',
array(
'%effect_name' => $effect_name,
'%ieid' => $ieids[$effect_name],
)));
}
// Image style overview form (ordering and renaming).
// Confirm the order of effects is maintained according to the order we
......@@ -196,10 +209,22 @@ function testStyle() {
$image_path = $this->createSampleImage($style);
$this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', array('%style' => $style->label(), '%file' => $image_path)));
// Test effect deletion form.
$effect = array_pop($style->effects);
$this->drupalPost($style_path . '/effects/' . $effect['ieid'] . '/delete', array(), t('Delete'));
$this->assertRaw(t('The image effect %name has been deleted.', array('%name' => $effect['label'])));
// Delete the 'image_crop' effect from the style.
$this->drupalPost($style_path . '/effects/' . $ieids['image_crop'] . '/delete', array(), t('Delete'));
// Confirm that the form submission was successful.
$this->assertResponse(200);
$this->assertRaw(t('The image effect %name has been deleted.', array('%name' => $style->effects[$ieids['image_crop']]['label'])));
// Confirm that there is no longer a link to the effect.
$this->assertNoLinkByHref($style_path . '/effects/' . $ieids['image_crop'] . '/delete');
// Refresh the image style information and verify that the effect was
// actually deleted.
$style = entity_load_unchanged('image_style', $style->id());
$this->assertFalse(isset($style->effects[$ieids['image_crop']]), format_string(
'Effect with ID %ieid no longer found on image style %style',
array(
'%ieid' => $ieids['image_crop'],
'%style' => $style->label,
)));
// Style deletion form.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment