Problem/Motivation
Using @expectedException is not considered good testing practice because you cannot specify where exactly in the test method the exception should be triggered. Background info: https://thephp.cc/news/2016/02/questioning-phpunit-best-practices
Proposed resolution
We should use the method setExpectedException() instead right before the line that triggers the exception (usually right before the last line).
Therefore @martin107 and @vaplas worked on an automated conversion script: https://github.com/martinfrances107/convertExceptions
Remaining tasks
Review patch.