Running phpunit against 8.x HEAD
phpunit --filter AjaxCommandsTest
PHPUnit 3.7.21 by Sebastian Bergmann.
Configuration read from /Volumes/devdisk/dev/sites/drupal8alt.dev/core/phpunit.xml.dist
................EE.....
Time: 03:55, Memory: 38.25Mb
There were 2 errors:
1) Drupal\Tests\Core\Ajax\AjaxCommandsTest::testOpenDialogCommand
Array to string conversion
/Volumes/devdisk/dev/sites/drupal8alt.dev/core/modules/views/tests/Drupal/views/Tests/Controller/ViewAjaxControllerTest.php:188
/Volumes/devdisk/dev/sites/drupal8alt.dev/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php:128
/Volumes/devdisk/dev/sites/drupal8alt.dev/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php:328
/usr/local/php5-5.4.16-20130615-025727/lib/php/PHPUnit/TextUI/Command.php:176
/usr/local/php5-5.4.16-20130615-025727/lib/php/PHPUnit/TextUI/Command.php:129
2) Drupal\Tests\Core\Ajax\AjaxCommandsTest::testOpenModalDialogCommand
Array to string conversion
/Volumes/devdisk/dev/sites/drupal8alt.dev/core/modules/views/tests/Drupal/views/Tests/Controller/ViewAjaxControllerTest.php:188
/Volumes/devdisk/dev/sites/drupal8alt.dev/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php:128
/Volumes/devdisk/dev/sites/drupal8alt.dev/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php:352
/usr/local/php5-5.4.16-20130615-025727/lib/php/PHPUnit/TextUI/Command.php:176
/usr/local/php5-5.4.16-20130615-025727/lib/php/PHPUnit/TextUI/Command.php:129
FAILURES!
Tests: 23, Assertions: 21, Errors: 2.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 2173171.4.patch | 749 bytes | alexpott |
| #1 | 2173171.1.patch | 753 bytes | alexpott |
Comments
Comment #1
alexpottThe problem is with the test version of
drupal_render()inDrupal\views\Tests\Controller\ViewAjaxControllerTest. TheAjaxCommandsTestresults indrupal_render()being called with an array consisting of only an item keyed by #attached.It is not necessary to cast the input to
drupal_render()to a string if the #markup key does not exist.This was broken by replacing
drupal_get_library()withdrupal_render()in\Drupal\Core\Ajax\OpenDialogCommanddone by #2171071: Rename drupal_add_library() to _drupal_add_library() and remove its usesConsidering D8 is supposed to have PHP 5.4 as a minimum version this is critical.
Comment #3
DeFr commentedReturning an array from a drupal_render implementation feels like a bug coming ; concatenating the drupal_render output with a string and using various string functions on the return is supposed to work, but with this patch it'll trigger another "Array to string conversion" warning.
If it doesn't, it probably means that this code isn't really hit, and simply returning an empty string should work ?
Comment #4
alexpott@DeFr well with the current implementation in this patch all the tests pass on 5.3 and 5.4. Which is not the case for HEAD. Personally, I find the practice of mocking procedural functions in tests a bit distasteful especially for a function that has the side effects that
drupal_render()can have. But we are where we are. It is really hard to know what the right thing to return here is - but I agree that we need to return a string as this is what drupal_render is supposed to do - so empty string it is.Comment #5
tim.plunkettVery true.
But, this change is fine for the unit test.
Comment #6
dawehnerYes, we should commit this like that, but we are having an actual other problem: the drupal_render method is overridden multiple times with different behavior. I think we should avoid that from the ground up, see my patch in https://drupal.org/comment/8374925#comment-8374925
Comment #7
webchickCommitted and pushed to 8.x. Thanks for the quick turnaround on this!