Hashar has uploaded a new change for review.

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

Change subject: Fix EchoTitleLocalCacheTest::testGet corner case
......................................................................

Fix EchoTitleLocalCacheTest::testGet corner case

EchoTitleLocalCache title cache resolution ends up querying the database
to resolve title id to Title object.

In some corner case, we might only have one page in the database (UTPage
as provided by MediaWikiTestCase), thus the id 2 would not resolve to a
Title breaking the test.

Use insertPage() to ensure we have a second page.

Bug: T78592
Change-Id: Ia9dbb256f566e489e1c81d89b6a6077831e07fc3
(cherry picked from commit 7f5b0c17933e781b3b29d5d66d068394a64b7d49)
---
M tests/phpunit/includes/cache/TitleLocalCacheTest.php
1 file changed, 9 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/20/184420/1

diff --git a/tests/phpunit/includes/cache/TitleLocalCacheTest.php 
b/tests/phpunit/includes/cache/TitleLocalCacheTest.php
index 5cc69e2..4746a92 100644
--- a/tests/phpunit/includes/cache/TitleLocalCacheTest.php
+++ b/tests/phpunit/includes/cache/TitleLocalCacheTest.php
@@ -30,7 +30,15 @@
                $lookups = $object->getProperty( 'lookups' );
                $lookups->setAccessible( true );
                $lookups->setValue( $cache, array( '1' => '1', '2' => '2' ) );
-               $this->assertTrue( count( $cache->getLookups() ) > 0 );
+
+               # A second page in addition to MediaWikiTestPage 'UTPage' since
+               # TitleLocalCache internally invokes Title::newFromIDs()
+               $this->insertPage('EchoTitleLocalCacheTest_testGet');
+               $titles = Title::newFromIDs( array( '1', '2' ) );
+               $this->assertEquals( 2, count( $titles ), "Must have at least 
two pages" );
+
+               $this->assertEquals( array(1 => '1', 2 => '2' ), 
$cache->getLookups() );
+
                // MapCacheLRU should treat key 1 same as '1'
                $this->assertInstanceOf( 'Title', $cache->get( '1' ) );
                $this->assertTrue( count( $cache->getLookups() ) > 0 );

-- 
To view, visit https://gerrit.wikimedia.org/r/184420
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia9dbb256f566e489e1c81d89b6a6077831e07fc3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: REL1_24
Gerrit-Owner: Hashar <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to