comparison core/modules/image/tests/src/Functional/ImageAdminStylesTest.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents c2387f117808
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php 1 <?php
2 2
3 namespace Drupal\Tests\image\Functional; 3 namespace Drupal\Tests\image\Functional;
4 4
5 use Drupal\Component\Utility\SafeMarkup; 5 use Drupal\Component\Render\FormattableMarkup;
6 use Drupal\Core\Entity\Entity\EntityViewDisplay; 6 use Drupal\Core\Entity\Entity\EntityViewDisplay;
7 use Drupal\image\Entity\ImageStyle; 7 use Drupal\image\Entity\ImageStyle;
8 use Drupal\image\ImageStyleInterface; 8 use Drupal\image\ImageStyleInterface;
9 use Drupal\node\Entity\Node; 9 use Drupal\node\Entity\Node;
10 use Drupal\file\Entity\File; 10 use Drupal\file\Entity\File;
150 foreach ($style->getEffects() as $uuid => $effect) { 150 foreach ($style->getEffects() as $uuid => $effect) {
151 // Store the uuid for later use. 151 // Store the uuid for later use.
152 $uuids[$effect->getPluginId()] = $uuid; 152 $uuids[$effect->getPluginId()] = $uuid;
153 $effect_configuration = $effect->getConfiguration(); 153 $effect_configuration = $effect->getConfiguration();
154 foreach ($effect_edits[$effect->getPluginId()] as $field => $value) { 154 foreach ($effect_edits[$effect->getPluginId()] as $field => $value) {
155 $this->assertEqual($value, $effect_configuration['data'][$field], SafeMarkup::format('The %field field in the %effect effect has the correct value of %value.', ['%field' => $field, '%effect' => $effect->getPluginId(), '%value' => $value])); 155 $this->assertEqual($value, $effect_configuration['data'][$field], new FormattableMarkup('The %field field in the %effect effect has the correct value of %value.', ['%field' => $field, '%effect' => $effect->getPluginId(), '%value' => $value]));
156 } 156 }
157 } 157 }
158 158
159 // Assert that every effect was saved. 159 // Assert that every effect was saved.
160 foreach (array_keys($effect_edits) as $effect_name) { 160 foreach (array_keys($effect_edits) as $effect_name) {
197 197
198 // Create an image to make sure it gets flushed after saving. 198 // Create an image to make sure it gets flushed after saving.
199 $image_path = $this->createSampleImage($style); 199 $image_path = $this->createSampleImage($style);
200 $this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', ['%style' => $style->label(), '%file' => $image_path])); 200 $this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', ['%style' => $style->label(), '%file' => $image_path]));
201 201
202 $this->drupalPostForm($style_path, $edit, t('Update style')); 202 $this->drupalPostForm($style_path, $edit, t('Save'));
203 203
204 // Note that after changing the style name, the style path is changed. 204 // Note that after changing the style name, the style path is changed.
205 $style_path = 'admin/config/media/image-styles/manage/' . $style_name; 205 $style_path = 'admin/config/media/image-styles/manage/' . $style_name;
206 206
207 // Check that the URL was updated. 207 // Check that the URL was updated.
335 $new_style_label = $this->randomString(); 335 $new_style_label = $this->randomString();
336 $edit = [ 336 $edit = [
337 'name' => $new_style_name, 337 'name' => $new_style_name,
338 'label' => $new_style_label, 338 'label' => $new_style_label,
339 ]; 339 ];
340 $this->drupalPostForm($style_path . $style_name, $edit, t('Update style')); 340 $this->drupalPostForm($style_path . $style_name, $edit, t('Save'));
341 $this->assertText(t('Changes to the style have been saved.'), format_string('Style %name was renamed to %new_name.', ['%name' => $style_name, '%new_name' => $new_style_name])); 341 $this->assertText(t('Changes to the style have been saved.'), format_string('Style %name was renamed to %new_name.', ['%name' => $style_name, '%new_name' => $new_style_name]));
342 $this->drupalGet('node/' . $nid); 342 $this->drupalGet('node/' . $nid);
343 343
344 // Reload the image style using the new name. 344 // Reload the image style using the new name.
345 $style = ImageStyle::load($new_style_name); 345 $style = ImageStyle::load($new_style_name);