Page MenuHomePhabricator

ApiQueryTitleBlacklistTest::testCheckingBlackListedTitle fails: 'blacklisted' != 'ok'
Closed, ResolvedPublic

Description

With MediaWiki core and TitleBlacklist extensions, an extension test fails when run after some MediaWiki tests:

$ php phpunit.php --filter Api
There was 1 failure:

1) ApiQueryTitleBlacklistTest::testCheckingBlackListedTitle
Listed title returns error
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'blacklisted'
+'ok'

extensions/TitleBlacklist/tests/phpunit/ApiQueryTitleBlacklistTest.php:90

Standalone is OK:

$ php phpunit.php --filter ApiQueryTitleBlacklistTest
Using PHP 5.6.29-0+deb8u1
PHPUnit 4.8.31 by Sebastian Bergmann and contributors.

...S..

Time: 3.81 seconds, Memory: 187.50MB

OK, but incomplete, skipped, or risky tests!
Tests: 6, Assertions: 9, Skipped: 1.

Event Timeline

hashar created this task.Jan 23 2017, 9:59 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 23 2017, 9:59 AM
hashar updated the task description. (Show Details)Jan 23 2017, 10:01 AM
hashar added a comment.EditedJan 23 2017, 10:13 AM

That comes from tests/phpunit/includes/api/ApiWatchTest.php I reproduce when running ApiWatchTest::testWatchProtect() before ApiQueryTitleBlacklistTest::testCheckingBlackListedTitle

Found it. TitleBlacklist is a singleton, it is loaded when the ApiWatchTest tests are runwith an empty $wgTitleBlacklistSources. The empty black/white lists ends up being cached for later tests.

ApiQueryTitleBlacklistTest set the global wgTitleBlacklistSources but the singleton is not reset. Hence the failure.

Change 333590 had a related patch set uploaded (by Hashar):
TitleBlacklistTest singleton can now be destroyed

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

Change 333590 merged by jenkins-bot:
TitleBlacklistTest singleton can now be destroyed

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

Change 333864 had a related patch set uploaded (by Hashar):
TitleBlacklistTest singleton can now be destroyed

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

Change 333864 merged by jenkins-bot:
TitleBlacklistTest singleton can now be destroyed

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

Change 333869 had a related patch set uploaded (by Hashar):
TitleBlacklistTest singleton can now be destroyed

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

Change 333869 merged by Hashar:
TitleBlacklistTest singleton can now be destroyed

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

Backported to 1.27/1.28. Will probably have to backport to 1.23 as well but running tests is broken for that branch as of now.

hashar triaged this task as Normal priority.Jun 16 2017, 11:07 AM
Krinkle moved this task from Inbox to PHPUnit on the MediaWiki-Core-Testing board.Jul 7 2017, 5:09 AM
Krinkle closed this task as Resolved.Apr 18 2018, 12:18 AM
Krinkle claimed this task.