mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Thanks
synced 2024-11-15 02:54:23 +00:00
ApiCoreThankIntegrationTest: Fix intermittent failures
Every time the setup function runs, it chooses a random page name with random content. If it chooses a page name + content combination that was used to set up a different test in the same run, the edit it makes will be a null edit, the revid will be null, and the test will crash. There are 100 possible page names and 100 possible page texts, so 10k possibilities total, and the setup function appears to be called 10 times, so the probability of a collision would have been (10 choose 2)/10000 = 0.0045 = 0.45%, or one in every 222 times. Bug: T151878 Change-Id: I800ee8512c2ad171ba793bea343f456653f9a16d
This commit is contained in:
parent
8f6eff3aea
commit
5f9f913fb6
|
@ -29,7 +29,16 @@ class ApiCoreThankIntegrationTest extends ApiTestCase {
|
|||
|
||||
// You can't thank yourself, kind of hacky but just use this other user
|
||||
$this->doLogin( 'uploader' );
|
||||
$result = $this->editPage( __CLASS__ . rand( 0, 100 ), __CLASS__ . rand( 0, 100 ) );
|
||||
|
||||
$pageName = __CLASS__;
|
||||
$content = __CLASS__;
|
||||
$pageTitle = Title::newFromText( $pageName );
|
||||
// If the page already exists, delete it, otherwise our edit will not result in a new revision
|
||||
if ( $pageTitle->exists() ) {
|
||||
$wikiPage = WikiPage::factory( $pageTitle );
|
||||
$wikiPage->doDeleteArticleReal( '' );
|
||||
}
|
||||
$result = $this->editPage( $pageName, $content );
|
||||
/** @var Status $result */
|
||||
$result = $result->getValue();
|
||||
/** @var Revision $revision */
|
||||
|
|
Loading…
Reference in a new issue