Problem
There is GD specific code in Rotate::validateArguments.
Generally, in GD toolkit operation classes (like, gd/Resize gd/Scale etc.) we only have calls to GD functions in their 'execute' methods.
This blocks #2578563: [PP-1] ImageToolkitOperations need traits as it is needed to have toolkit agnostic traits for the ::arguments
and ::validateArguments
methods for all image toolkit operations, so that contrib toolkits could benefit from those without having to re-add boilerplate code. See the Image Effects module for an example of using traits shared by GD and ImageMagick toolkits operations.
Proposed resolution
- Move GD specific code from
::validateArguments
to::execute
- Add test coverage.
The change in the test to add the mock logger is because, with the change to validateArguments() when the exception is thrown, it tries to log it.
Some out of scope changes can be done in follow-up #2796369: [PP-1] Cleanup gd/Rotate::execute() arguments array overloading
Remaining tasks
Review patch. Note changes might make more sense when looking at it in context.
User interface changes
None
API changes
None
Original report by @YesCT
original bug is no longer an issue
1. the new OS X builds have the toolkit
2. the test doesn't actually perform changes to images
In the test class it already stubbed out the 'execute' method of the image toolkit operations, so we can test the Image class without actually performing changes to images (this relates to the original issue report about testRotate() failing).
report was
On PHP 5.5.14 unit tests fail Drupal\Tests\Core\Image\ImageTest::testRotate imagecolorallocatealpha() expects parameter 1 to be resource, null given
Follow-up to #2463879: PHP unit tests fail if intl extension is missing
On running phpunit tests:
https://www.drupal.org/node/2116263
./vendor/bin/phpunit --filter=ImageTest
will run just the one class with the test that fails.
PHP 5.5.14
mac os x native /usr/bin/php
There was 1 error:
1) Drupal\Tests\Core\Image\ImageTest::testRotate
imagecolorallocatealpha() expects parameter 1 to be resource, null given
/Users/ctheys/foo/drupal/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php:60
/Users/ctheys/foo/drupal/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php:177
/Users/ctheys/foo/drupal/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php:127
/Users/ctheys/foo/drupal/core/lib/Drupal/Core/Image/Image.php:148
/Users/ctheys/foo/drupal/core/lib/Drupal/Core/Image/Image.php:190
/Users/ctheys/foo/drupal/core/tests/Drupal/Tests/Core/Image/ImageTest.php:455
FAILURES!
Tests: 7631, Assertions: 40525, Errors: 1, Incomplete: 2.
php -i | grep "GD Version"
GD Version => bundled (2.1.0 compatible)
MAMP php's
PHP 5.4.34
Tests: 7631, Assertions: 40527, Incomplete: 2.
PHP 5.5.18
Tests: 7631, Assertions: 40527, Incomplete: 2.
PHP 5.6.2
Tests: 7631, Assertions: 40527, Incomplete: 2.