Commit 81407f18 authored by Eloy Lafuente's avatar Eloy Lafuente
Browse files

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
parent 8a14a7bd
...@@ -149,7 +149,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { ...@@ -149,7 +149,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
public function test_get_config_file_contents_with_single_run() { public function test_get_config_file_contents_with_single_run() {
$mockbuilder = $this->getMockBuilder('behat_config_util'); $mockbuilder = $this->getMockBuilder('behat_config_util');
$mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme', 'get_theme_config')); $mockbuilder->onlyMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme', 'get_theme_config'));
$behatconfigutil = $mockbuilder->getMock(); $behatconfigutil = $mockbuilder->getMock();
...@@ -188,7 +188,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { ...@@ -188,7 +188,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
public function test_get_config_file_contents_with_single_run_no_theme() { public function test_get_config_file_contents_with_single_run_no_theme() {
$mockbuilder = $this->getMockBuilder('behat_config_util'); $mockbuilder = $this->getMockBuilder('behat_config_util');
$mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme', 'get_theme_config')); $mockbuilder->onlyMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme', 'get_theme_config'));
$behatconfigutil = $mockbuilder->getMock(); $behatconfigutil = $mockbuilder->getMock();
...@@ -242,7 +242,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { ...@@ -242,7 +242,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
public function test_get_config_file_contents_with_parallel_run() { public function test_get_config_file_contents_with_parallel_run() {
$mockbuilder = $this->getMockBuilder('behat_config_util'); $mockbuilder = $this->getMockBuilder('behat_config_util');
$mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme', 'get_theme_config')); $mockbuilder->onlyMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme', 'get_theme_config'));
$behatconfigutil = $mockbuilder->getMock(); $behatconfigutil = $mockbuilder->getMock();
...@@ -345,7 +345,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { ...@@ -345,7 +345,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
public function test_get_config_file_contents_with_parallel_run_optimize_tags() { public function test_get_config_file_contents_with_parallel_run_optimize_tags() {
$mockbuilder = $this->getMockBuilder('behat_config_util'); $mockbuilder = $this->getMockBuilder('behat_config_util');
$mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme', 'get_theme_config')); $mockbuilder->onlyMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme', 'get_theme_config'));
$behatconfigutil = $mockbuilder->getMock(); $behatconfigutil = $mockbuilder->getMock();
...@@ -489,7 +489,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { ...@@ -489,7 +489,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
public function test_get_config_file_contents_with_blacklisted_tags() { public function test_get_config_file_contents_with_blacklisted_tags() {
$mockbuilder = $this->getMockBuilder('behat_config_util'); $mockbuilder = $this->getMockBuilder('behat_config_util');
$mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_blacklisted_tests_for_theme', $mockbuilder->onlyMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_blacklisted_tests_for_theme',
'get_default_theme', 'get_theme_config')); 'get_default_theme', 'get_theme_config'));
$behatconfigutil = $mockbuilder->getMock(); $behatconfigutil = $mockbuilder->getMock();
...@@ -553,7 +553,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { ...@@ -553,7 +553,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
public function test_get_config_file_contents_with_blacklisted_features_contexts() { public function test_get_config_file_contents_with_blacklisted_features_contexts() {
$mockbuilder = $this->getMockBuilder('behat_config_util'); $mockbuilder = $this->getMockBuilder('behat_config_util');
$mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_blacklisted_tests_for_theme', $mockbuilder->onlyMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_blacklisted_tests_for_theme',
'get_default_theme', 'get_theme_config')); 'get_default_theme', 'get_theme_config'));
$behatconfigutil = $mockbuilder->getMock(); $behatconfigutil = $mockbuilder->getMock();
...@@ -632,7 +632,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { ...@@ -632,7 +632,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
public function test_core_features_to_include_in_specified_theme() { public function test_core_features_to_include_in_specified_theme() {
$mockbuilder = $this->getMockBuilder('behat_config_util'); $mockbuilder = $this->getMockBuilder('behat_config_util');
$mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme', 'get_theme_config')); $mockbuilder->onlyMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_default_theme', 'get_theme_config'));
$behatconfigutil = $mockbuilder->getMock(); $behatconfigutil = $mockbuilder->getMock();
......
...@@ -857,7 +857,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -857,7 +857,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredcontext->save(); $expiredcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_users_in_context', 'delete_data_for_users_in_context',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
...@@ -868,7 +868,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -868,7 +868,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$mockprivacymanager->expects($this->never())->method('delete_data_for_users_in_context'); $mockprivacymanager->expects($this->never())->method('delete_data_for_users_in_context');
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->method('get_privacy_manager')->willReturn($mockprivacymanager); $manager->method('get_privacy_manager')->willReturn($mockprivacymanager);
...@@ -935,7 +935,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -935,7 +935,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredcontext->save(); $expiredcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_users_in_context', 'delete_data_for_users_in_context',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
...@@ -956,7 +956,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -956,7 +956,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
})); }));
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->method('get_privacy_manager')->willReturn($mockprivacymanager); $manager->method('get_privacy_manager')->willReturn($mockprivacymanager);
...@@ -1023,7 +1023,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1023,7 +1023,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredcontext->save(); $expiredcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_users_in_context', 'delete_data_for_users_in_context',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
...@@ -1044,7 +1044,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1044,7 +1044,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
})); }));
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->method('get_privacy_manager')->willReturn($mockprivacymanager); $manager->method('get_privacy_manager')->willReturn($mockprivacymanager);
...@@ -1112,7 +1112,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1112,7 +1112,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredcontext->save(); $expiredcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_users_in_context', 'delete_data_for_users_in_context',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
...@@ -1133,7 +1133,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1133,7 +1133,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
})); }));
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->method('get_privacy_manager')->willReturn($mockprivacymanager); $manager->method('get_privacy_manager')->willReturn($mockprivacymanager);
...@@ -1208,7 +1208,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1208,7 +1208,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredcontext->save(); $expiredcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_users_in_context', 'delete_data_for_users_in_context',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
...@@ -1229,7 +1229,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1229,7 +1229,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
})); }));
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->method('get_privacy_manager')->willReturn($mockprivacymanager); $manager->method('get_privacy_manager')->willReturn($mockprivacymanager);
...@@ -1260,7 +1260,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1260,7 +1260,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredcontext->save(); $expiredcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
]) ])
...@@ -1269,7 +1269,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1269,7 +1269,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context'); $mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context');
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->set_progress(new \null_progress_trace()); $manager->set_progress(new \null_progress_trace());
...@@ -1299,7 +1299,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1299,7 +1299,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredcontext->save(); $expiredcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
]) ])
...@@ -1308,7 +1308,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1308,7 +1308,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context'); $mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context');
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->set_progress(new \null_progress_trace()); $manager->set_progress(new \null_progress_trace());
...@@ -1335,7 +1335,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1335,7 +1335,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredcontext->save(); $expiredcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
]) ])
...@@ -1344,7 +1344,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1344,7 +1344,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context'); $mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context');
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->set_progress(new \null_progress_trace()); $manager->set_progress(new \null_progress_trace());
...@@ -1382,7 +1382,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1382,7 +1382,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredcontext->save(); $expiredcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
]) ])
...@@ -1396,7 +1396,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1396,7 +1396,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
); );
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->set_progress(new \null_progress_trace()); $manager->set_progress(new \null_progress_trace());
...@@ -1442,7 +1442,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1442,7 +1442,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredcontext->save(); $expiredcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
]) ])
...@@ -1451,7 +1451,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1451,7 +1451,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$mockprivacymanager->expects($this->once())->method('delete_data_for_all_users_in_context'); $mockprivacymanager->expects($this->once())->method('delete_data_for_all_users_in_context');
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->set_progress(new \null_progress_trace()); $manager->set_progress(new \null_progress_trace());
...@@ -1494,7 +1494,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1494,7 +1494,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$this->setUser(); $this->setUser();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
]) ])
...@@ -1503,7 +1503,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1503,7 +1503,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context'); $mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context');
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->set_progress(new \null_progress_trace()); $manager->set_progress(new \null_progress_trace());
...@@ -1546,7 +1546,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1546,7 +1546,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
set_config('siteadmins', implode(',', $admins)); set_config('siteadmins', implode(',', $admins));
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
]) ])
...@@ -1555,7 +1555,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1555,7 +1555,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context'); $mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context');
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->set_progress(new \null_progress_trace()); $manager->set_progress(new \null_progress_trace());
...@@ -1600,7 +1600,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1600,7 +1600,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredblockcontext->save(); $expiredblockcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
]) ])
...@@ -1614,7 +1614,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1614,7 +1614,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
); );
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->set_progress(new \null_progress_trace()); $manager->set_progress(new \null_progress_trace());
...@@ -1653,7 +1653,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1653,7 +1653,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredusercontext->save(); $expiredusercontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
]) ])
...@@ -1667,7 +1667,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1667,7 +1667,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
); );
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->set_progress(new \null_progress_trace()); $manager->set_progress(new \null_progress_trace());
...@@ -1705,7 +1705,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1705,7 +1705,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredcontext->save(); $expiredcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
]) ])
...@@ -1714,7 +1714,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1714,7 +1714,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context'); $mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context');
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->set_progress(new \null_progress_trace()); $manager->set_progress(new \null_progress_trace());
$manager->method('get_privacy_manager')->willReturn($mockprivacymanager); $manager->method('get_privacy_manager')->willReturn($mockprivacymanager);
...@@ -1756,7 +1756,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1756,7 +1756,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredcontext->save(); $expiredcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
]) ])
...@@ -1765,7 +1765,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1765,7 +1765,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context'); $mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context');
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->set_progress(new \null_progress_trace()); $manager->set_progress(new \null_progress_trace());
...@@ -1814,7 +1814,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1814,7 +1814,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredforumcontext->save(); $expiredforumcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
]) ])
...@@ -1823,7 +1823,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1823,7 +1823,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context'); $mockprivacymanager->expects($this->never())->method('delete_data_for_all_users_in_context');
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->set_progress(new \null_progress_trace()); $manager->set_progress(new \null_progress_trace());
...@@ -1872,7 +1872,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1872,7 +1872,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
$expiredforumcontext->save(); $expiredforumcontext->save();
$mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class) $mockprivacymanager = $this->getMockBuilder(\core_privacy\manager::class)
->setMethods([ ->onlyMethods([
'delete_data_for_user', 'delete_data_for_user',
'delete_data_for_all_users_in_context', 'delete_data_for_all_users_in_context',
]) ])
...@@ -1886,7 +1886,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase { ...@@ -1886,7 +1886,7 @@ class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
); );
$manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class) $manager = $this->getMockBuilder(\tool_dataprivacy\expired_contexts_manager::class)
->setMethods(['get_privacy_manager']) ->onlyMethods(['get_privacy_manager'])
->getMock(); ->getMock();
$manager->set_progress(new \null_progress_trace()); $manager->set_progress(new \null_progress_trace());
......
...@@ -42,7 +42,7 @@ class tool_dataprivacy_filtered_userlist_testcase extends advanced_testcase { ...@@ -42,7 +42,7 @@ class tool_dataprivacy_filtered_userlist_testcase extends advanced_testcase {
public function test_apply_expired_contexts_filters(array $initial, array $expired, array $unexpired, array $expected) { public function test_apply_expired_contexts_filters(array $initial, array $expired, array $unexpired, array $expected) {
$userlist = $this->getMockBuilder(\tool_dataprivacy\filtered_userlist::class) $userlist = $this->getMockBuilder(\tool_dataprivacy\filtered_userlist::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods(null) ->onlyMethods([])
->getMock(); ->getMock();
$rc = new \ReflectionClass(\tool_dataprivacy\filtered_userlist::class); $rc = new \ReflectionClass(\tool_dataprivacy\filtered_userlist::class);
......
...@@ -42,7 +42,7 @@ class locale_testcase extends \advanced_testcase { ...@@ -42,7 +42,7 @@ class locale_testcase extends \advanced_testcase {
// - second setlocale() call which try to set new 'es' locale // - second setlocale() call which try to set new 'es' locale
// - third setlocale() call which restore locale.