diff --git a/modules/image/image.module b/modules/image/image.module index 71fba37971..91419048f2 100644 --- a/modules/image/image.module +++ b/modules/image/image.module @@ -583,8 +583,10 @@ function image_styles() { $style['storage'] = IMAGE_STORAGE_DEFAULT; foreach ($style['effects'] as $key => $effect) { $definition = image_effect_definition_load($effect['name']); - $effect = array_merge($definition, $effect); - $style['effects'][$key] = $effect; + if ($definition) { + $effect = array_merge($definition, $effect); + $style['effects'][$key] = $effect; + } } $styles[$style_name] = $style; } diff --git a/modules/image/image.test b/modules/image/image.test index 07eb4cedc1..e5bb220d37 100644 --- a/modules/image/image.test +++ b/modules/image/image.test @@ -31,7 +31,7 @@ class ImageFieldTestCase extends DrupalWebTestCase { protected $admin_user; function setUp() { - parent::setUp('image'); + parent::setUp(array_unique(array_merge(array('image'), array_pop(func_get_args())))); $this->admin_user = $this->drupalCreateUser(array('access content', 'access administration pages', 'administer site configuration', 'administer content types', 'administer nodes', 'create article content', 'edit any article content', 'delete any article content', 'administer image styles', 'administer fields')); $this->drupalLogin($this->admin_user); } @@ -573,6 +573,10 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase { ); } + function setUp() { + parent::setUp('image_module_test', 'image_module_styles_test'); + } + /** * Given an image style, generate an image. */ @@ -893,6 +897,20 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase { $this->drupalGet('node/' . $nid); $this->assertRaw(check_plain(image_style_url('thumbnail', $node->{$field_name}[LANGUAGE_NONE][0]['uri'])), format_string('Image displayed using style replacement style.')); } + + /** + * Test adding an effect to a style then removing the providing module. + */ + function testOrphanedEffect() { + $style_name = 'test_image_style'; + $style_label = 'Test Image Style'; + + module_disable(array('image_module_test'), FALSE); + $this->drupalGet('admin/config/media/image-styles'); + $this->assertText($style_label, 'Image style with an orphaned effect displayed in the list of styles.'); + //$this->drupalGet('admin/config/media/image-styles/edit/' . $style_name); + //$this->assertRaw(t('Edit %name style', array('%name' => $style_label)), 'Image style with an orphaned effect remains editable.'); + } } /** diff --git a/modules/image/tests/image_module_styles_test.info b/modules/image/tests/image_module_styles_test.info new file mode 100644 index 0000000000..aa6a975c8a --- /dev/null +++ b/modules/image/tests/image_module_styles_test.info @@ -0,0 +1,7 @@ +name = Image Styles test +description = Provides additional hook implementations for testing Image Styles functionality. +package = Core +version = VERSION +core = 7.x +files[] = image_module_styles_test.module +hidden = TRUE diff --git a/modules/image/tests/image_module_styles_test.module b/modules/image/tests/image_module_styles_test.module new file mode 100644 index 0000000000..79929d9399 --- /dev/null +++ b/modules/image/tests/image_module_styles_test.module @@ -0,0 +1,29 @@ + 'Test Image Style', + 'effects' => array( + array( + 'name' => 'image_scale', + 'data' => array('width' => 100, 'height' => 100, 'upscale' => 1), + 'weight' => 0, + ), + array( + 'name' => 'image_module_test_null', + ), + ) + ); + + return $styles; +} diff --git a/modules/image/tests/image_module_test.module b/modules/image/tests/image_module_test.module index fc66d9b8b7..e7ae716e7a 100644 --- a/modules/image/tests/image_module_test.module +++ b/modules/image/tests/image_module_test.module @@ -20,7 +20,8 @@ function image_module_test_file_download($uri) { function image_module_test_image_effect_info() { $effects = array( 'image_module_test_null' => array( - 'effect callback' => 'image_module_test_null_effect', + 'label' => 'image_module_test_null', + 'effect callback' => 'image_module_test_null_effect', ), ); @@ -38,7 +39,7 @@ function image_module_test_image_effect_info() { * @return * TRUE */ -function image_module_test_null_effect(array &$image, array $data) { +function image_module_test_null_effect(&$image, array $data) { return TRUE; }