ChangeTagsTest: Mark tables as "used" to avoid ID reuse
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 9 Oct 2018 19:41:25 +0000 (15:41 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Tue, 9 Oct 2018 19:52:05 +0000 (15:52 -0400)
If ChangeTags::updateTags() isn't passed all three of $rc_id, $rev_id,
and $log_id, it attempts to look up proper values from the subset that
is passed.

Some of the tests in ChangeTagsTest blindly use certain IDs, expecting
them to either not exist in the relevant tables or at least to be sane
(e.g. the same log_id isn't used on multiple rc_id rows). Depending on
the exact behavior of previous tests, this expectation may not hold.

The simple fix is to just mark the relevant tables as "used" by
ChangeTagsTest so MediaWikiTestCase will truncate them.

Change-Id: Ie60092b8a6e50f6f8a5cfdaaf4cac8ddb4fc6f53

tests/phpunit/includes/changetags/ChangeTagsTest.php

index 64c3224..f207564 100644 (file)
@@ -15,6 +15,14 @@ class ChangeTagsTest extends MediaWikiTestCase {
                $this->tablesUsed[] = 'change_tag_def';
                $this->tablesUsed[] = 'tag_summary';
                $this->tablesUsed[] = 'valid_tag';
+
+               // Truncate these to avoid the supposed-to-be-unused IDs in tests here turning
+               // out to be used, leading ChangeTags::updateTags() to pick up bogus rc_id,
+               // log_id, or rev_id values and run into unique constraint violations.
+               $this->tablesUsed[] = 'recentchanges';
+               $this->tablesUsed[] = 'logging';
+               $this->tablesUsed[] = 'revision';
+               $this->tablesUsed[] = 'archive';
        }
 
        // TODO only modifyDisplayQuery and getSoftwareTags are tested, nothing else is