-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
The behaviour of at() is confusing. Using at() leads to brittle tests at best and lying tests at worst. The documentation even states:
The
$indexparameter for theat()matcher refers to the index, starting at zero, in all method invocations for a given mock object. Exercise caution when using this matcher as it can lead to brittle tests which are too closely tied to specific implementation details.
Furthermore, the implementation of at() impedes improvements to other aspects of the test doubles support in PHPUnit, see #4291 (comment) for example.
We should therefore deprecate
PHPUnit\Framework\TestCase::at()(as well as thePHPUnit\Framework\at()wrapper)PHPUnit\Framework\MockObject\Rule\InvokedAtIndex
in PHPUnit 9 and remove it in PHPUnit 10.
If we realize that a mechanism for specifying the order in which expected invocations occur then, and only then, shall we think about how to best implement this. A replacement for at() is explicitly outside the scope of this deprecation.