diff --git a/core/modules/image/src/Tests/ImageFieldWidgetTest.php b/core/modules/image/src/Tests/ImageFieldWidgetTest.php index 8bc70bc..252f4f7 100644 --- a/core/modules/image/src/Tests/ImageFieldWidgetTest.php +++ b/core/modules/image/src/Tests/ImageFieldWidgetTest.php @@ -7,6 +7,8 @@ namespace Drupal\image\Tests; +use Drupal\field\Entity\FieldConfig; + /** * Tests the image field widget. * @@ -30,6 +32,22 @@ public function testWidgetElement() { $this->createImageField($field_name, 'article', array(), $field_settings); $this->drupalGet('node/add/article'); $this->assertNotEqual(0, count($this->xpath('//div[contains(@class, "field--widget-image-image")]')), 'Image field widget found on add/node page', 'Browser'); + + // Check for allowed image file extensions - default. + $this->assertText('Allowed types: png gif jpg jpeg.'); + + // Try adding to the field config an unsupported extension, should not + // appear in the allowed types. + $field_config = FieldConfig::loadByName('node', 'article', $field_name); + $field_config ->setSetting('file_extensions', 'png gif jpg jpeg tiff')->save(); + $this->drupalGet('node/add/article'); + $this->assertText('Allowed types: png gif jpg jpeg.'); + + // Add a supported extension and remove some supported ones, we should see + // the intersect of those entered in field config with those supported. + $field_config ->setSetting('file_extensions', 'png jpe tiff')->save(); + $this->drupalGet('node/add/article'); + $this->assertText('Allowed types: png jpe.'); } } diff --git a/core/modules/system/src/Tests/Image/ToolkitGdTest.php b/core/modules/system/src/Tests/Image/ToolkitGdTest.php index a731f5b..ef90e71 100644 --- a/core/modules/system/src/Tests/Image/ToolkitGdTest.php +++ b/core/modules/system/src/Tests/Image/ToolkitGdTest.php @@ -111,6 +111,11 @@ function testManipulations() { // Test that the image factory is set to use the GD toolkit. $this->assertEqual($this->imageFactory->getToolkitId(), 'gd', 'The image factory is set to use the \'gd\' image toolkit.'); + // Test the list of supported extensions. + $expected_extensions = ['png', 'gif', 'jpeg', 'jpg', 'jpe']; + $supported_extensions = $this->imageFactory->getSupportedExtensions(); + $this->assertEqual($expected_extensions, array_intersect($expected_extensions, $supported_extensions)); + // Typically the corner colors will be unchanged. These colors are in the // order of top-left, top-right, bottom-right, bottom-left. $default_corners = array($this->red, $this->green, $this->blue, $this->transparent);