diff --git a/core/lib/Drupal/Core/Image/Image.php b/core/lib/Drupal/Core/Image/Image.php index f5b89dc..a8e86e0 100644 --- a/core/lib/Drupal/Core/Image/Image.php +++ b/core/lib/Drupal/Core/Image/Image.php @@ -72,7 +72,8 @@ class Image implements ImageInterface { * Constructs a new Image object. * * @param string $source - * The path to an image file. + * The path to an image file, or NULL to construct the object with no + * image source. * @param \Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit * The image toolkit. */ diff --git a/core/lib/Drupal/Core/Image/ImageFactory.php b/core/lib/Drupal/Core/Image/ImageFactory.php index 1c106b4..3ca56d7 100644 --- a/core/lib/Drupal/Core/Image/ImageFactory.php +++ b/core/lib/Drupal/Core/Image/ImageFactory.php @@ -39,10 +39,10 @@ public function __construct(ImageToolkitManager $toolkit_manager) { } /** - * Sets this factory image toolkit ID. + * Sets the ID of the image toolkit. * * @param string $toolkit_id - * The image toolkit ID to use for this image factory. + * The ID of the image toolkit to use for this image factory. * * @return self * Returns this image. @@ -53,10 +53,21 @@ public function setToolkitId($toolkit_id) { } /** - * Constructs a new Image object from an image file. + * Gets the ID of the image toolkit currently in use. + * + * @return string + * The ID of the image toolkit in use by the image factory. + */ + public function getToolkitId() { + return $this->resolveToolkitId(); + } + + /** + * Constructs a new Image object. * * @param string $source - * The path to an image file. + * The path to an image file, or NULL to construct the object with no + * image source. * @param string $toolkit_id * (Optional) The image toolkit ID to use for this image. * diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php index f6a3ace..ea6745d 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php @@ -190,7 +190,7 @@ public function scaleAndCrop(ImageInterface $image, $width, $height); * @param \Drupal\Core\Image\ImageInterface $image * An image object. * - * @return array|bool + * @return array|FALSE * FALSE, if the file could not be found or is not an image. Otherwise, a * keyed array containing information about the image: * - "type": Image type represented as an IMAGETYPE_* constant. diff --git a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php index 1506bba..14dff5e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php @@ -110,6 +110,10 @@ function getPixelColor(ImageInterface $image, $x, $y) { * the expected height and widths for the final images. */ 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.'); + // 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); diff --git a/core/tests/Drupal/Tests/Core/Image/ImageTest.php b/core/tests/Drupal/Tests/Core/Image/ImageTest.php index 1457e1c..d593881 100644 --- a/core/tests/Drupal/Tests/Core/Image/ImageTest.php +++ b/core/tests/Drupal/Tests/Core/Image/ImageTest.php @@ -55,11 +55,11 @@ protected function setUp() { * @param array $stubs * (optional) Array containing methods to be replaced with stubs. * - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit_Framework_MockObject_MockObject */ protected function getToolkitMock(array $stubs = array()) { $mock_builder = $this->getMockBuilder('Drupal\system\Plugin\ImageToolkit\GDToolkit'); - if ($stubs && is_array($stubs)) { + if (!empty($stubs)) { $stubs += array('getPluginId', 'save'); } else { @@ -190,7 +190,7 @@ public function testProcessInfoFails() { $toolkit = $this->getToolkitMock(); $image = new Image('magic-foobars.png', $toolkit); - $this->assertFalse((bool) $image->getWidth()); + $this->assertFalse($image->isExisting()); } /**