mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-71036 phpunit: Mock->setMethods() silently deprecated
The current ->setMethods() has been silently (won't emit any warning) in PHPUnit 9. And will stop working (current plans) in PHPUnit 10. Basically the now deprecated method has been split into: - onlyMethods(): To point to existing methods in the mocked artifact. - addMethods(): To point to non existing (yet) methods in the mocked artifact. In practice that means that all our current setMethods() calls can be converted to onlyMethods() (existing) and done. The addMethods() is mostly useful on development phases, not final testing. Finally note that <null> isn't accepted anymore as parameter to double all the methods. Instead empty array [] must be used. Link: https://github.com/sebastianbergmann/phpunit/issues/3770
This commit is contained in:
parent
8a14a7bd22
commit
81407f18ec
42 changed files with 181 additions and 181 deletions
|
@ -59,7 +59,7 @@ class component_favourite_service_testcase extends advanced_testcase {
|
|||
protected function get_mock_repository(array $mockstore) {
|
||||
// This mock will just store data in an array.
|
||||
$mockrepo = $this->getMockBuilder(\core_favourites\local\repository\favourite_repository_interface::class)
|
||||
->setMethods([])
|
||||
->onlyMethods([])
|
||||
->getMock();
|
||||
$mockrepo->expects($this->any())
|
||||
->method('add')
|
||||
|
|
|
@ -59,7 +59,7 @@ class user_favourite_service_testcase extends advanced_testcase {
|
|||
protected function get_mock_repository(array $mockstore) {
|
||||
// This mock will just store data in an array.
|
||||
$mockrepo = $this->getMockBuilder(\core_favourites\local\repository\favourite_repository_interface::class)
|
||||
->setMethods([])
|
||||
->onlyMethods([])
|
||||
->getMock();
|
||||
$mockrepo->expects($this->any())
|
||||
->method('add')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue