diff options
author | Nikki Nikkhoui <nnikkhoui@wikimedia.org> | 2022-03-10 14:53:20 -0500 |
---|---|---|
committer | Nikki Nikkhoui <nnikkhoui@wikimedia.org> | 2022-03-10 20:12:27 +0000 |
commit | f6780de05874bea602e528dce6d84f0c034a3f09 (patch) | |
tree | 1e17ef3e0d932a085ead27251aac1441d00dba5d /tests/phpunit/mocks/MockTitleTrait.php | |
parent | 26109fb098c7d2c4e43bb0884e200ed6855e4157 (diff) | |
download | mediawikicore-f6780de05874bea602e528dce6d84f0c034a3f09.tar.gz mediawikicore-f6780de05874bea602e528dce6d84f0c034a3f09.zip |
Set page id to 0 for pages in virtual namespaces
If we are creating a Mock title, the ID should be set to 0
for any Titles that are in "virtual" namespaces (e.g.
any with a namespace ID < 0, which is Special: or
Media:)
Change-Id: I6aae00ae8f68ad3a93d9edd1194e828735e2a878
Diffstat (limited to 'tests/phpunit/mocks/MockTitleTrait.php')
-rw-r--r-- | tests/phpunit/mocks/MockTitleTrait.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/phpunit/mocks/MockTitleTrait.php b/tests/phpunit/mocks/MockTitleTrait.php index 1c2e71bc6885..14b3c6849cec 100644 --- a/tests/phpunit/mocks/MockTitleTrait.php +++ b/tests/phpunit/mocks/MockTitleTrait.php @@ -25,8 +25,12 @@ trait MockTitleTrait { * @return Title|MockObject */ private function makeMockTitle( $text, array $props = [] ) { - $id = $props['id'] ?? ++$this->pageIdCounter; $ns = $props['namespace'] ?? 0; + if ( $ns < 0 ) { + $id = 0; + } else { + $id = $props['id'] ?? ++$this->pageIdCounter; + } $nsName = $ns ? "ns$ns:" : ''; $preText = $text; |