Chris@0: drupalGetTestFiles('image'); Chris@0: $file = reset($files); Chris@0: $file_path = file_unmanaged_copy($file->uri); Chris@0: } Chris@0: Chris@0: return $style->buildUrl($file_path) ? $file_path : FALSE; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Count the number of images currently create for a style. Chris@0: */ Chris@0: public function getImageCount(ImageStyleInterface $style) { Chris@0: return count(file_scan_directory('public://styles/' . $style->id(), '/.*/')); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Test creating an image style with a numeric name and ensuring it can be Chris@0: * applied to an image. Chris@0: */ Chris@0: public function testNumericStyleName() { Chris@0: $style_name = rand(); Chris@0: $style_label = $this->randomString(); Chris@0: $edit = [ Chris@0: 'name' => $style_name, Chris@0: 'label' => $style_label, Chris@0: ]; Chris@0: $this->drupalPostForm('admin/config/media/image-styles/add', $edit, t('Create new style')); Chris@0: $this->assertRaw(t('Style %name was created.', ['%name' => $style_label])); Chris@0: $options = image_style_options(); Chris@0: $this->assertTrue(array_key_exists($style_name, $options), format_string('Array key %key exists.', ['%key' => $style_name])); Chris@0: } Chris@0: Chris@0: /** Chris@0: * General test to add a style, add/remove/edit effects to it, then delete it. Chris@0: */ Chris@0: public function testStyle() { Chris@0: $admin_path = 'admin/config/media/image-styles'; Chris@0: Chris@0: // Setup a style to be created and effects to add to it. Chris@0: $style_name = strtolower($this->randomMachineName(10)); Chris@0: $style_label = $this->randomString(); Chris@0: $style_path = $admin_path . '/manage/' . $style_name; Chris@0: $effect_edits = [ Chris@0: 'image_resize' => [ Chris@0: 'width' => 100, Chris@0: 'height' => 101, Chris@0: ], Chris@0: 'image_scale' => [ Chris@0: 'width' => 110, Chris@0: 'height' => 111, Chris@0: 'upscale' => 1, Chris@0: ], Chris@0: 'image_scale_and_crop' => [ Chris@0: 'width' => 120, Chris@0: 'height' => 121, Chris@0: ], Chris@0: 'image_crop' => [ Chris@0: 'width' => 130, Chris@0: 'height' => 131, Chris@0: 'anchor' => 'left-top', Chris@0: ], Chris@0: 'image_desaturate' => [ Chris@0: // No options for desaturate. Chris@0: ], Chris@0: 'image_rotate' => [ Chris@0: 'degrees' => 5, Chris@0: 'random' => 1, Chris@0: 'bgcolor' => '#FFFF00', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // Add style form. Chris@0: Chris@0: $edit = [ Chris@0: 'name' => $style_name, Chris@0: 'label' => $style_label, Chris@0: ]; Chris@0: $this->drupalPostForm($admin_path . '/add', $edit, t('Create new style')); Chris@0: $this->assertRaw(t('Style %name was created.', ['%name' => $style_label])); Chris@0: Chris@0: // Ensure that the expected entity operations are there. Chris@0: $this->drupalGet($admin_path); Chris@0: $this->assertLinkByHref($style_path); Chris@0: $this->assertLinkByHref($style_path . '/flush'); Chris@0: $this->assertLinkByHref($style_path . '/delete'); Chris@0: Chris@0: // Add effect form. Chris@0: Chris@0: // Add each sample effect to the style. Chris@0: foreach ($effect_edits as $effect => $edit) { Chris@0: $edit_data = []; Chris@0: foreach ($edit as $field => $value) { Chris@0: $edit_data['data[' . $field . ']'] = $value; Chris@0: } Chris@0: // Add the effect. Chris@0: $this->drupalPostForm($style_path, ['new' => $effect], t('Add')); Chris@0: if (!empty($edit)) { Chris@0: $this->drupalPostForm(NULL, $edit_data, t('Add effect')); Chris@0: } Chris@0: } Chris@0: Chris@0: // Load the saved image style. Chris@0: $style = ImageStyle::load($style_name); Chris@0: Chris@0: // Ensure that third party settings were added to the config entity. Chris@0: // These are added by a hook_image_style_presave() implemented in Chris@0: // image_module_test module. Chris@0: $this->assertEqual('bar', $style->getThirdPartySetting('image_module_test', 'foo'), 'Third party settings were added to the image style.'); Chris@0: Chris@0: // Ensure that the image style URI matches our expected path. Chris@0: $style_uri_path = $style->url(); Chris@0: $this->assertTrue(strpos($style_uri_path, $style_path) !== FALSE, 'The image style URI is correct.'); Chris@0: Chris@0: // Confirm that all effects on the image style have settings that match Chris@0: // what was saved. Chris@0: $uuids = []; Chris@0: foreach ($style->getEffects() as $uuid => $effect) { Chris@0: // Store the uuid for later use. Chris@0: $uuids[$effect->getPluginId()] = $uuid; Chris@0: $effect_configuration = $effect->getConfiguration(); Chris@0: foreach ($effect_edits[$effect->getPluginId()] as $field => $value) { Chris@0: $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])); Chris@0: } Chris@0: } Chris@0: Chris@0: // Assert that every effect was saved. Chris@0: foreach (array_keys($effect_edits) as $effect_name) { Chris@0: $this->assertTrue(isset($uuids[$effect_name]), format_string( Chris@0: 'A %effect_name effect was saved with ID %uuid', Chris@0: [ Chris@0: '%effect_name' => $effect_name, Chris@0: '%uuid' => $uuids[$effect_name], Chris@0: ])); Chris@0: } Chris@0: Chris@0: // Image style overview form (ordering and renaming). Chris@0: Chris@0: // Confirm the order of effects is maintained according to the order we Chris@0: // added the fields. Chris@0: $effect_edits_order = array_keys($effect_edits); Chris@0: $order_correct = TRUE; Chris@0: $index = 0; Chris@0: foreach ($style->getEffects() as $effect) { Chris@0: if ($effect_edits_order[$index] != $effect->getPluginId()) { Chris@0: $order_correct = FALSE; Chris@0: } Chris@0: $index++; Chris@0: } Chris@0: $this->assertTrue($order_correct, 'The order of the effects is correctly set by default.'); Chris@0: Chris@0: // Test the style overview form. Chris@0: // Change the name of the style and adjust the weights of effects. Chris@0: $style_name = strtolower($this->randomMachineName(10)); Chris@0: $style_label = $this->randomMachineName(); Chris@0: $weight = count($effect_edits); Chris@0: $edit = [ Chris@0: 'name' => $style_name, Chris@0: 'label' => $style_label, Chris@0: ]; Chris@0: foreach ($style->getEffects() as $uuid => $effect) { Chris@0: $edit['effects[' . $uuid . '][weight]'] = $weight; Chris@0: $weight--; Chris@0: } Chris@0: Chris@0: // Create an image to make sure it gets flushed after saving. Chris@0: $image_path = $this->createSampleImage($style); Chris@0: $this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', ['%style' => $style->label(), '%file' => $image_path])); Chris@0: Chris@0: $this->drupalPostForm($style_path, $edit, t('Update style')); Chris@0: Chris@0: // Note that after changing the style name, the style path is changed. Chris@0: $style_path = 'admin/config/media/image-styles/manage/' . $style_name; Chris@0: Chris@0: // Check that the URL was updated. Chris@0: $this->drupalGet($style_path); Chris@0: $this->assertTitle(t('Edit style @name | Drupal', ['@name' => $style_label])); Chris@0: $this->assertResponse(200, format_string('Image style %original renamed to %new', ['%original' => $style->id(), '%new' => $style_name])); Chris@0: Chris@0: // Check that the available image effects are properly sorted. Chris@0: $option = $this->xpath('//select[@id=:id]//option', [':id' => 'edit-new--2']); Chris@0: $this->assertTrue($option[1] == 'Ajax test', '"Ajax test" is the first selectable effect.'); Chris@0: Chris@0: // Check that the image was flushed after updating the style. Chris@0: // This is especially important when renaming the style. Make sure that Chris@0: // the old image directory has been deleted. Chris@0: $this->assertEqual($this->getImageCount($style), 0, format_string('Image style %style was flushed after renaming the style and updating the order of effects.', ['%style' => $style->label()])); Chris@0: Chris@0: // Load the style by the new name with the new weights. Chris@0: $style = ImageStyle::load($style_name); Chris@0: Chris@0: // Confirm the new style order was saved. Chris@0: $effect_edits_order = array_reverse($effect_edits_order); Chris@0: $order_correct = TRUE; Chris@0: $index = 0; Chris@0: foreach ($style->getEffects() as $effect) { Chris@0: if ($effect_edits_order[$index] != $effect->getPluginId()) { Chris@0: $order_correct = FALSE; Chris@0: } Chris@0: $index++; Chris@0: } Chris@0: $this->assertTrue($order_correct, 'The order of the effects is correctly set by default.'); Chris@0: Chris@0: // Image effect deletion form. Chris@0: Chris@0: // Create an image to make sure it gets flushed after deleting an effect. Chris@0: $image_path = $this->createSampleImage($style); Chris@0: $this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', ['%style' => $style->label(), '%file' => $image_path])); Chris@0: Chris@0: // Delete the 'image_crop' effect from the style. Chris@0: $this->drupalPostForm($style_path . '/effects/' . $uuids['image_crop'] . '/delete', [], t('Delete')); Chris@0: // Confirm that the form submission was successful. Chris@0: $this->assertResponse(200); Chris@0: $image_crop_effect = $style->getEffect($uuids['image_crop']); Chris@0: $this->assertRaw(t('The image effect %name has been deleted.', ['%name' => $image_crop_effect->label()])); Chris@0: // Confirm that there is no longer a link to the effect. Chris@0: $this->assertNoLinkByHref($style_path . '/effects/' . $uuids['image_crop'] . '/delete'); Chris@0: // Refresh the image style information and verify that the effect was Chris@0: // actually deleted. Chris@0: $entity_type_manager = $this->container->get('entity_type.manager'); Chris@0: $style = $entity_type_manager->getStorage('image_style')->loadUnchanged($style->id()); Chris@0: $this->assertFalse($style->getEffects()->has($uuids['image_crop']), format_string( Chris@0: 'Effect with ID %uuid no longer found on image style %style', Chris@0: [ Chris@0: '%uuid' => $uuids['image_crop'], Chris@0: '%style' => $style->label(), Chris@0: ])); Chris@0: Chris@0: // Additional test on Rotate effect, for transparent background. Chris@0: $edit = [ Chris@0: 'data[degrees]' => 5, Chris@0: 'data[random]' => 0, Chris@0: 'data[bgcolor]' => '', Chris@0: ]; Chris@0: $this->drupalPostForm($style_path, ['new' => 'image_rotate'], t('Add')); Chris@0: $this->drupalPostForm(NULL, $edit, t('Add effect')); Chris@0: $entity_type_manager = $this->container->get('entity_type.manager'); Chris@0: $style = $entity_type_manager->getStorage('image_style')->loadUnchanged($style_name); Chris@0: $this->assertEqual(count($style->getEffects()), 6, 'Rotate effect with transparent background was added.'); Chris@0: Chris@0: // Style deletion form. Chris@0: Chris@0: // Delete the style. Chris@0: $this->drupalPostForm($style_path . '/delete', [], t('Delete')); Chris@0: Chris@0: // Confirm the style directory has been removed. Chris@0: $directory = file_default_scheme() . '://styles/' . $style_name; Chris@0: $this->assertFalse(is_dir($directory), format_string('Image style %style directory removed on style deletion.', ['%style' => $style->label()])); Chris@0: Chris@0: $this->assertFalse(ImageStyle::load($style_name), format_string('Image style %style successfully deleted.', ['%style' => $style->label()])); Chris@0: Chris@0: // Test empty text when there are no image styles. Chris@0: Chris@0: // Delete all image styles. Chris@0: foreach (ImageStyle::loadMultiple() as $image_style) { Chris@0: $image_style->delete(); Chris@0: } Chris@0: Chris@0: // Confirm that the empty text is correct on the image styles page. Chris@0: $this->drupalGet($admin_path); Chris@0: $this->assertRaw(t('There are currently no styles. Add a new one.', [ Chris@0: ':url' => \Drupal::url('image.style_add'), Chris@0: ])); Chris@0: Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests editing Ajax-enabled image effect forms. Chris@0: */ Chris@0: public function testAjaxEnabledEffectForm() { Chris@0: $admin_path = 'admin/config/media/image-styles'; Chris@0: Chris@0: // Setup a style to be created and effects to add to it. Chris@0: $style_name = strtolower($this->randomMachineName(10)); Chris@0: $style_label = $this->randomString(); Chris@0: $style_path = $admin_path . '/manage/' . $style_name; Chris@0: $effect_edit = [ Chris@0: 'data[test_parameter]' => 100, Chris@0: ]; Chris@0: Chris@0: // Add style form. Chris@0: $edit = [ Chris@0: 'name' => $style_name, Chris@0: 'label' => $style_label, Chris@0: ]; Chris@0: $this->drupalPostForm($admin_path . '/add', $edit, t('Create new style')); Chris@0: $this->assertRaw(t('Style %name was created.', ['%name' => $style_label])); Chris@0: Chris@0: // Add two Ajax-enabled test effects. Chris@0: $this->drupalPostForm($style_path, ['new' => 'image_module_test_ajax'], t('Add')); Chris@0: $this->drupalPostForm(NULL, $effect_edit, t('Add effect')); Chris@0: $this->drupalPostForm($style_path, ['new' => 'image_module_test_ajax'], t('Add')); Chris@0: $this->drupalPostForm(NULL, $effect_edit, t('Add effect')); Chris@0: Chris@0: // Load the saved image style. Chris@0: $style = ImageStyle::load($style_name); Chris@0: Chris@0: // Edit back the effects. Chris@0: foreach ($style->getEffects() as $uuid => $effect) { Chris@0: $effect_path = $admin_path . '/manage/' . $style_name . '/effects/' . $uuid; Chris@0: $this->drupalGet($effect_path); Chris@0: $this->drupalPostAjaxForm(NULL, $effect_edit, ['op' => t('Ajax refresh')]); Chris@0: $this->drupalPostForm(NULL, $effect_edit, t('Update effect')); Chris@0: } Chris@0: Chris@0: } Chris@0: Chris@0: /** Chris@0: * Test deleting a style and choosing a replacement style. Chris@0: */ Chris@0: public function testStyleReplacement() { Chris@0: // Create a new style. Chris@0: $style_name = strtolower($this->randomMachineName(10)); Chris@0: $style_label = $this->randomString(); Chris@0: $style = ImageStyle::create(['name' => $style_name, 'label' => $style_label]); Chris@0: $style->save(); Chris@0: $style_path = 'admin/config/media/image-styles/manage/'; Chris@0: Chris@0: // Create an image field that uses the new style. Chris@0: $field_name = strtolower($this->randomMachineName(10)); Chris@0: $this->createImageField($field_name, 'article'); Chris@0: entity_get_display('node', 'article', 'default') Chris@0: ->setComponent($field_name, [ Chris@0: 'type' => 'image', Chris@0: 'settings' => ['image_style' => $style_name], Chris@0: ]) Chris@0: ->save(); Chris@0: Chris@0: // Create a new node with an image attached. Chris@0: $test_image = current($this->drupalGetTestFiles('image')); Chris@0: $nid = $this->uploadNodeImage($test_image, $field_name, 'article', $this->randomMachineName()); Chris@0: $node = Node::load($nid); Chris@0: Chris@0: // Get node field original image URI. Chris@0: $fid = $node->get($field_name)->target_id; Chris@0: $original_uri = File::load($fid)->getFileUri(); Chris@0: Chris@0: // Test that image is displayed using newly created style. Chris@0: $this->drupalGet('node/' . $nid); Chris@0: $this->assertRaw(file_url_transform_relative($style->buildUrl($original_uri)), format_string('Image displayed using style @style.', ['@style' => $style_name])); Chris@0: Chris@0: // Rename the style and make sure the image field is updated. Chris@0: $new_style_name = strtolower($this->randomMachineName(10)); Chris@0: $new_style_label = $this->randomString(); Chris@0: $edit = [ Chris@0: 'name' => $new_style_name, Chris@0: 'label' => $new_style_label, Chris@0: ]; Chris@0: $this->drupalPostForm($style_path . $style_name, $edit, t('Update style')); Chris@0: $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])); Chris@0: $this->drupalGet('node/' . $nid); Chris@0: Chris@0: // Reload the image style using the new name. Chris@0: $style = ImageStyle::load($new_style_name); Chris@0: $this->assertRaw(file_url_transform_relative($style->buildUrl($original_uri)), 'Image displayed using style replacement style.'); Chris@0: Chris@0: // Delete the style and choose a replacement style. Chris@0: $edit = [ Chris@0: 'replacement' => 'thumbnail', Chris@0: ]; Chris@0: $this->drupalPostForm($style_path . $new_style_name . '/delete', $edit, t('Delete')); Chris@0: $message = t('The image style %name has been deleted.', ['%name' => $new_style_label]); Chris@0: $this->assertRaw($message); Chris@0: Chris@0: $replacement_style = ImageStyle::load('thumbnail'); Chris@0: $this->drupalGet('node/' . $nid); Chris@0: $this->assertRaw(file_url_transform_relative($replacement_style->buildUrl($original_uri)), 'Image displayed using style replacement style.'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Verifies that editing an image effect does not cause it to be duplicated. Chris@0: */ Chris@0: public function testEditEffect() { Chris@0: // Add a scale effect. Chris@0: $style_name = 'test_style_effect_edit'; Chris@0: $this->drupalGet('admin/config/media/image-styles/add'); Chris@0: $this->drupalPostForm(NULL, ['label' => 'Test style effect edit', 'name' => $style_name], t('Create new style')); Chris@0: $this->drupalPostForm(NULL, ['new' => 'image_scale_and_crop'], t('Add')); Chris@0: $this->drupalPostForm(NULL, ['data[width]' => '300', 'data[height]' => '200'], t('Add effect')); Chris@0: $this->assertText(t('Scale and crop 300×200')); Chris@0: Chris@0: // There should normally be only one edit link on this page initially. Chris@0: $this->clickLink(t('Edit')); Chris@0: $this->drupalPostForm(NULL, ['data[width]' => '360', 'data[height]' => '240'], t('Update effect')); Chris@0: $this->assertText(t('Scale and crop 360×240')); Chris@0: Chris@0: // Check that the previous effect is replaced. Chris@0: $this->assertNoText(t('Scale and crop 300×200')); Chris@0: Chris@0: // Add another scale effect. Chris@0: $this->drupalGet('admin/config/media/image-styles/add'); Chris@0: $this->drupalPostForm(NULL, ['label' => 'Test style scale edit scale', 'name' => 'test_style_scale_edit_scale'], t('Create new style')); Chris@0: $this->drupalPostForm(NULL, ['new' => 'image_scale'], t('Add')); Chris@0: $this->drupalPostForm(NULL, ['data[width]' => '12', 'data[height]' => '19'], t('Add effect')); Chris@0: Chris@0: // Edit the scale effect that was just added. Chris@0: $this->clickLink(t('Edit')); Chris@0: $this->drupalPostForm(NULL, ['data[width]' => '24', 'data[height]' => '19'], t('Update effect')); Chris@14: Chris@14: // Add another scale effect and make sure both exist. Click through from Chris@14: // the overview to make sure that it is possible to add new effect then. Chris@14: $this->drupalGet('admin/config/media/image-styles'); Chris@14: $rows = $this->xpath('//table/tbody/tr'); Chris@14: $i = 0; Chris@14: foreach ($rows as $row) { Chris@14: if (((string) $row->td[0]) === 'Test style scale edit scale') { Chris@14: $this->clickLink('Edit', $i); Chris@14: break; Chris@14: } Chris@14: $i++; Chris@14: } Chris@0: $this->drupalPostForm(NULL, ['new' => 'image_scale'], t('Add')); Chris@0: $this->drupalPostForm(NULL, ['data[width]' => '12', 'data[height]' => '19'], t('Add effect')); Chris@0: $this->assertText(t('Scale 24×19')); Chris@0: $this->assertText(t('Scale 12×19')); Chris@0: Chris@0: // Try to edit a nonexistent effect. Chris@0: $uuid = $this->container->get('uuid'); Chris@0: $this->drupalGet('admin/config/media/image-styles/manage/' . $style_name . '/effects/' . $uuid->generate()); Chris@0: $this->assertResponse(404); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Test flush user interface. Chris@0: */ Chris@0: public function testFlushUserInterface() { Chris@0: $admin_path = 'admin/config/media/image-styles'; Chris@0: Chris@0: // Create a new style. Chris@0: $style_name = strtolower($this->randomMachineName(10)); Chris@0: $style = ImageStyle::create(['name' => $style_name, 'label' => $this->randomString()]); Chris@0: $style->save(); Chris@0: Chris@0: // Create an image to make sure it gets flushed. Chris@0: $files = $this->drupalGetTestFiles('image'); Chris@0: $image_uri = $files[0]->uri; Chris@0: $derivative_uri = $style->buildUri($image_uri); Chris@0: $this->assertTrue($style->createDerivative($image_uri, $derivative_uri)); Chris@0: $this->assertEqual($this->getImageCount($style), 1); Chris@0: Chris@0: // Go to image styles list page and check if the flush operation link Chris@0: // exists. Chris@0: $this->drupalGet($admin_path); Chris@0: $flush_path = $admin_path . '/manage/' . $style_name . '/flush'; Chris@0: $this->assertLinkByHref($flush_path); Chris@0: Chris@0: // Flush the image style derivatives using the user interface. Chris@0: $this->drupalPostForm($flush_path, [], t('Flush')); Chris@0: Chris@0: // The derivative image file should have been deleted. Chris@0: $this->assertEqual($this->getImageCount($style), 0); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests image style configuration import that does a delete. Chris@0: */ Chris@0: public function testConfigImport() { Chris@0: // Create a new style. Chris@0: $style_name = strtolower($this->randomMachineName(10)); Chris@0: $style_label = $this->randomString(); Chris@0: $style = ImageStyle::create(['name' => $style_name, 'label' => $style_label]); Chris@0: $style->save(); Chris@0: Chris@0: // Create an image field that uses the new style. Chris@0: $field_name = strtolower($this->randomMachineName(10)); Chris@0: $this->createImageField($field_name, 'article'); Chris@0: entity_get_display('node', 'article', 'default') Chris@0: ->setComponent($field_name, [ Chris@0: 'type' => 'image', Chris@0: 'settings' => ['image_style' => $style_name], Chris@0: ]) Chris@0: ->save(); Chris@0: Chris@0: // Create a new node with an image attached. Chris@0: $test_image = current($this->drupalGetTestFiles('image')); Chris@0: $nid = $this->uploadNodeImage($test_image, $field_name, 'article', $this->randomMachineName()); Chris@0: $node = Node::load($nid); Chris@0: Chris@0: // Get node field original image URI. Chris@0: $fid = $node->get($field_name)->target_id; Chris@0: $original_uri = File::load($fid)->getFileUri(); Chris@0: Chris@0: // Test that image is displayed using newly created style. Chris@0: $this->drupalGet('node/' . $nid); Chris@0: $this->assertRaw(file_url_transform_relative($style->buildUrl($original_uri)), format_string('Image displayed using style @style.', ['@style' => $style_name])); Chris@0: Chris@0: // Copy config to sync, and delete the image style. Chris@0: $sync = $this->container->get('config.storage.sync'); Chris@0: $active = $this->container->get('config.storage'); Chris@0: // Remove the image field from the display, to avoid a dependency error Chris@0: // during import. Chris@0: EntityViewDisplay::load('node.article.default') Chris@0: ->removeComponent($field_name) Chris@0: ->save(); Chris@0: $this->copyConfig($active, $sync); Chris@0: $sync->delete('image.style.' . $style_name); Chris@0: $this->configImporter()->import(); Chris@0: Chris@0: $this->assertFalse(ImageStyle::load($style_name), 'Style deleted after config import.'); Chris@0: $this->assertEqual($this->getImageCount($style), 0, 'Image style was flushed after being deleted by config import.'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests access for the image style listing. Chris@0: */ Chris@0: public function testImageStyleAccess() { Chris@0: $style = ImageStyle::create(['name' => 'style_foo', 'label' => $this->randomString()]); Chris@0: $style->save(); Chris@0: Chris@0: $this->drupalGet('admin/config/media/image-styles'); Chris@0: $this->clickLink(t('Edit')); Chris@0: $this->assertRaw(t('Select a new effect')); Chris@0: } Chris@0: Chris@0: }