jenkins-bot has submitted this change and it was merged.
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(-)
Approvals:
Hashar: Looks good to me, approved
jenkins-bot: Verified
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/184343
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia9dbb256f566e489e1c81d89b6a6077831e07fc3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: wmf/1.25wmf13
Gerrit-Owner: Hashar <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits