aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/api
diff options
context:
space:
mode:
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>2021-04-22 10:40:46 +0200
committerThiemo Kreuz <thiemo.kreuz@wikimedia.de>2021-04-23 11:58:58 +0200
commitb95a07380a64e72581a8bf41f466f58a1901ecb1 (patch)
treec4c271c16b01c10685f4bef807b71d1e2a41bf2d /tests/phpunit/includes/api
parent791aa5e30666ab10736266e1d04c506aec771d96 (diff)
downloadmediawikicore-b95a07380a64e72581a8bf41f466f58a1901ecb1.tar.gz
mediawikicore-b95a07380a64e72581a8bf41f466f58a1901ecb1.zip
Remove meaningless ->expects( $this->any() ) from all tests
It is not entirely meaningless. It might be an indicator that the number of calls to a method is intentionally unlimited. This is similar to e.g. an @inheritDoc PHPDoc comment that marks a method as being "intentionally undocumented". However, what's the meaning of being "intentionally unconstrained"? Let's just not have any constraint then. I feel all these ->expects( $this->any() ) bloat the test code so much that it's never worth it. Change-Id: I9925e7706bd03e1666f6eb0b284cb42b0dd3be23
Diffstat (limited to 'tests/phpunit/includes/api')
-rw-r--r--tests/phpunit/includes/api/ApiMainTest.php6
-rw-r--r--tests/phpunit/includes/api/ApiOpenSearchTest.php3
-rw-r--r--tests/phpunit/includes/api/ApiOptionsTest.php6
3 files changed, 5 insertions, 10 deletions
diff --git a/tests/phpunit/includes/api/ApiMainTest.php b/tests/phpunit/includes/api/ApiMainTest.php
index 1036152ffcb0..776a1eca81ca 100644
--- a/tests/phpunit/includes/api/ApiMainTest.php
+++ b/tests/phpunit/includes/api/ApiMainTest.php
@@ -528,8 +528,7 @@ class ApiMainTest extends ApiTestCase {
->setConstructorArgs( [ $api, 'mock' ] )
->onlyMethods( [ 'getConditionalRequestData' ] )
->getMockForAbstractClass();
- $module->expects( $this->any() )
- ->method( 'getConditionalRequestData' )
+ $module->method( 'getConditionalRequestData' )
->will( $this->returnCallback( static function ( $condition ) use ( $conditions ) {
return $conditions[$condition] ?? null;
} ) );
@@ -659,8 +658,7 @@ class ApiMainTest extends ApiTestCase {
->setConstructorArgs( [ $api, 'mock' ] )
->onlyMethods( [ 'getConditionalRequestData' ] )
->getMockForAbstractClass();
- $module->expects( $this->any() )
- ->method( 'getConditionalRequestData' )
+ $module->method( 'getConditionalRequestData' )
->will( $this->returnCallback( static function ( $condition ) use ( $conditions ) {
return $conditions[$condition] ?? null;
} ) );
diff --git a/tests/phpunit/includes/api/ApiOpenSearchTest.php b/tests/phpunit/includes/api/ApiOpenSearchTest.php
index 68df7afeb393..05dfa4c1f5c2 100644
--- a/tests/phpunit/includes/api/ApiOpenSearchTest.php
+++ b/tests/phpunit/includes/api/ApiOpenSearchTest.php
@@ -11,8 +11,7 @@ class ApiOpenSearchTest extends MediaWikiIntegrationTestCase {
$api = $this->createApi();
$engine = $this->replaceSearchEngine();
- $engine->expects( $this->any() )
- ->method( 'getProfiles' )
+ $engine->method( 'getProfiles' )
->will( $this->returnValueMap( [
[ SearchEngine::COMPLETION_PROFILE_TYPE, $api->getUser(), [
[
diff --git a/tests/phpunit/includes/api/ApiOptionsTest.php b/tests/phpunit/includes/api/ApiOptionsTest.php
index 3395b12e4eca..a2097e185c69 100644
--- a/tests/phpunit/includes/api/ApiOptionsTest.php
+++ b/tests/phpunit/includes/api/ApiOptionsTest.php
@@ -32,8 +32,7 @@ class ApiOptionsTest extends MediaWikiLangTestCase {
$this->mUserMock->method( 'getEffectiveGroups' )->willReturn( [ '*', 'user' ] );
// Set up callback for User::getOptionKinds
- $this->mUserMock->expects( $this->any() )
- ->method( 'getOptionKinds' )->will( $this->returnCallback( [ $this, 'getOptionKinds' ] ) );
+ $this->mUserMock->method( 'getOptionKinds' )->will( $this->returnCallback( [ $this, 'getOptionKinds' ] ) );
// No actual DB data
$this->mUserMock->method( 'getInstanceForUpdate' )->willReturn( $this->mUserMock );
@@ -42,8 +41,7 @@ class ApiOptionsTest extends MediaWikiLangTestCase {
$this->mUserMock->method( 'getOptions' )
->willReturn( [] );
- $this->mUserMock->expects( $this->any() )
- ->method( 'isAllowedAny' )->willReturn( true );
+ $this->mUserMock->method( 'isAllowedAny' )->willReturn( true );
// DefaultPreferencesFactory calls a ton of user methods, but we still want to list all of
// them in case bugs are caused by unexpected things returning null that shouldn't.