$this->assertFieldByName($field,$value,t('The %field field in the %effect effect has the correct value of %value.',array('%field'=>$field,'%effect'=>$effect['name'],'%value'=>$value)));
}
}
// Image style overview form (ordering and renaming).
// Confirm the order of effects is maintained according to the order we
// added the fields.
$effect_edits_order=array_keys($effect_edits);
$effects_order=array_values($style['effects']);
$order_correct=TRUE;
foreach($effects_orderas$index=>$effect){
if($effect_edits_order[$index]!=$effect['name']){
$order_correct=FALSE;
}
}
$this->assertTrue($order_correct,t('The order of the effects is correctly set by default.'));
// Test the style overview form.
// Change the name of the style and adjust the weights of effects.
$style_name=strtolower($this->randomName(10));
$weight=count($effect_edits);
$edit=array(
'name'=>$style_name,
);
foreach($style['effects']as$ieid=>$effect){
$edit['effects['.$ieid.'][weight]']=$weight;
$weight--;
}
// Create an image to make sure it gets flushed after saving.
$this->assertResponse(200,t('Image style %original renamed to %new',array('%original'=>$style['name'],'%new'=>$style_name)));
// Check that the image was flushed after updating the style.
// This is especially important when renaming the style. Make sure that
// the old image directory has been deleted.
$this->assertEqual($this->getImageCount($style),0,t('Image style %style was flushed after renaming the style and updating the order of effects.',array('%style'=>$style['name'])));
// Load the style by the new name with the new weights.
// Test that image is displayed using newly created style.
$this->drupalGet('node/'.$nid);
$this->assertRaw(image_style_url($style_name,$node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['uri']),t('Image displayed using style @style.',array('@style'=>$style_name)));
// Rename the style and make sure the image field is updated.
$this->assertText(t('Changes to the style have been saved.'),t('Style %name was renamed to %new_name.',array('%name'=>$style_name,'%new_name'=>$new_style_name)));
$this->drupalGet('node/'.$nid);
$this->assertRaw(image_style_url($new_style_name,$node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['uri']),t('Image displayed using style replacement style.'));
// Delete the style and choose a replacement style.