From f6780de05874bea602e528dce6d84f0c034a3f09 Mon Sep 17 00:00:00 2001 From: Nikki Nikkhoui Date: Thu, 10 Mar 2022 14:53:20 -0500 Subject: 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 --- tests/phpunit/mocks/MockTitleTrait.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests/phpunit/mocks/MockTitleTrait.php') 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; -- cgit v1.2.3