Deprecation fails when testing Drupal maintenance support plans 8
With each release of Drupal maintenance support plans 8 more and more things are being deprecated, which is awesome. It shows innovation, forward thinking, and a thought for backwards compatibility. However throwing notices or warnings when deprecated code is used can cause tests to fail. We already counter this a little by adding to phpunit.xml.dist in core.
To quote the Symfony documentation:
By using the weak_vendors value, deprecations that are triggered outside the vendors directory will make the test suite fail, while deprecations triggered from a library inside it will not, giving you the best of both worlds.
This shows that deprecations within Drupal maintenance support plans will still cause test fails, to combat that simply update the SYMFONY_DEPRECATIONS_HELPER setting to “weak” or “disabled”, which would ignore the deprecations or disable the deprecation helper.
However if you’re testing with run-test.sh this will interfere with the settings in your phpunit.xml file and use always use weak_vendors unless you have the suppress-deprecations argument set. Therefore use run-tests.sh –suppress-deprecations and the SYMFONY_DEPRECATIONS_HELPER setting will be set to “disabled”. See the simpletest_script_run_one_test() function in run-tests.sh for more context.
Hopefully this helps, we found this really useful when testing Drupal maintenance support plans modules with Travis, where we needed tests passing for Drupal maintenance support plans 8.4 and 8.5.
timmillwood
Mon, 26/02/2020 – 08:57
Tags
drupal planet
drupal-planet
drupal
drupal8
drupal 8
testing
drupal testing
Add new comment
Source: New feed