-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Description
When upgrading to a newer phpunit, you will start getting warnings that amongst some getMock
is deprecated and createMock
should be used instead.
According to the contribution page, 4.2 or higher is required. Symfony doesn't have its own dependency on phpunit and thus it's up to the contributors to use the proper versions. Now that phpunit is picking up speed and starts dropping unsupported php versions and features, things change fast.
In phpunit 5.4 the biggest change is the deprecation of getMock
. If this method is used with only 1 argument, it has to be replaced by createMock
and if the other arguments were passed along, getMockBuilder
should be used instead.
As symfony doesn't really have a constraint on phpunit other than 4.2+, you will run into some small issues:
$ f getMock -G "Test/"
src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php
96: $translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface');
97: $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
98: $contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface');
src/Symfony/Component/Form/Test/TypeTestCase.php
33: $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
The first one I don't know but the second one is used as a base class for form type tests. Besides of this, the test code might have to change as well as getMock
is being deprecated. I can create a patch for those cases to check if createMock exists and call it instead or use the mock builder for example.
Besides of this issue, I would like to bring up the discussion of the supported phpunit versions and how to actively keep the tests up-to-date.
- Should the phpunit-bridge create a BC layer to avoid those issues in the future and expose a custom API?
- Should the minimal phpunit version be bumped to something that's still maintained?
- Minor versions are not supported for very long and the major for a year. Maybe the minimum phpunit version should always be
<current major>.0.0
?