Page MenuHomePhabricator

IPInfo unit tests raise warnings
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • php phpunit.php ../../extensions/IPInfo/tests/phpunit/unit/Rest/Handler/RevisionHandlerTest.php
  • Enjoy your warnings
There were 2 warnings:

1) MediaWiki\IPInfo\Test\Unit\Rest\Handler\RevisionHandlerTest::testExecuteErrors with data set "Access denied, registered" (array(true), array('ipinfo-rest-access-denied', 403))
Method userHasRight may not return value of type NULL, its return declaration is ": bool"

2) MediaWiki\IPInfo\Test\Unit\Rest\Handler\RevisionHandlerTest::testExecuteErrors with data set "Access denied, anon" (array(false), array('ipinfo-rest-access-denied', 401))
Method userHasRight may not return value of type NULL, its return declaration is ": bool"

WARNINGS!
Tests: 9, Assertions: 42, Warnings: 2.

What happens?:
The return declaration of userHasRight and userCan has been changed to bool recently in this patch, but the unit tests in tests/phpunit/unit/Rest/Handler/RevisionHandlerTest.php of IPInfo extension has not been updated yet:

$permissionManager->method( 'userHasRight' )
			->willReturn( $options['userHasRight'] ?? null );  // here, should assume false rather than null; the same for userCan

What should have happened instead?:
No warnings :)

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.: master

Event Timeline

Change 801966 had a related patch set uploaded (by WhitePhosphorus; author: WhitePhosphorus):

[mediawiki/extensions/IPInfo@master] Update some return types in unit tests

https://gerrit.wikimedia.org/r/801966

Change 801966 merged by jenkins-bot:

[mediawiki/extensions/IPInfo@master] Update some return types in unit tests

https://gerrit.wikimedia.org/r/801966