diff options
author | C. Scott Ananian <cscott@cscott.net> | 2024-05-16 16:15:16 -0400 |
---|---|---|
committer | C. Scott Ananian <cscott@cscott.net> | 2024-06-17 13:24:39 +0000 |
commit | 105bb58ae2049ebe0fc55c5ca541c3e8b630cc77 (patch) | |
tree | 18f09f63d8d7e0594bc95db0c1a4e1dd1b6f970f /tests/phpunit/includes/jobqueue | |
parent | 82760471ac5efaa86985f01fc260c9385605ac86 (diff) | |
download | mediawikicore-105bb58ae2049ebe0fc55c5ca541c3e8b630cc77.tar.gz mediawikicore-105bb58ae2049ebe0fc55c5ca541c3e8b630cc77.zip |
[ParsoidCachePrewarmJob] Use ParserOutputAccess
One more step in gradually replacing uses of ParsoidOutputAccess. This
one was pretty easy, as ParsoidOutputAccess was pretty much directly
calling ParserOutputAccess when provided with a ExistingPageRecord
and RevisionRecord.
Bug: T367074
Change-Id: I96161a64952e1809c0aec773d5a3dd4c71105657
Diffstat (limited to 'tests/phpunit/includes/jobqueue')
-rw-r--r-- | tests/phpunit/includes/jobqueue/JobFactoryTest.php | 2 | ||||
-rw-r--r-- | tests/phpunit/includes/jobqueue/JobTest.php | 2 | ||||
-rw-r--r-- | tests/phpunit/includes/jobqueue/jobs/ParsoidCachePrewarmJobTest.php | 26 |
3 files changed, 19 insertions, 11 deletions
diff --git a/tests/phpunit/includes/jobqueue/JobFactoryTest.php b/tests/phpunit/includes/jobqueue/JobFactoryTest.php index 41fb21f3a16f..6a62fdfb3d20 100644 --- a/tests/phpunit/includes/jobqueue/JobFactoryTest.php +++ b/tests/phpunit/includes/jobqueue/JobFactoryTest.php @@ -48,7 +48,7 @@ class JobFactoryTest extends MediaWikiIntegrationTestCase { [ 'class' => ParsoidCachePrewarmJob::class, 'services' => [ - 'ParsoidOutputAccess', + 'ParserOutputAccess', 'PageStore', 'RevisionLookup', 'ParsoidSiteConfig', diff --git a/tests/phpunit/includes/jobqueue/JobTest.php b/tests/phpunit/includes/jobqueue/JobTest.php index 57b58798a838..da78a8754935 100644 --- a/tests/phpunit/includes/jobqueue/JobTest.php +++ b/tests/phpunit/includes/jobqueue/JobTest.php @@ -130,7 +130,7 @@ class JobTest extends MediaWikiIntegrationTestCase { [ 'class' => ParsoidCachePrewarmJob::class, 'services' => [ - 'ParsoidOutputAccess', + 'ParserOutputAccess', 'PageStore', 'RevisionLookup', 'ParsoidSiteConfig', diff --git a/tests/phpunit/includes/jobqueue/jobs/ParsoidCachePrewarmJobTest.php b/tests/phpunit/includes/jobqueue/jobs/ParsoidCachePrewarmJobTest.php index 891bf3d9c3a1..43905a266a46 100644 --- a/tests/phpunit/includes/jobqueue/jobs/ParsoidCachePrewarmJobTest.php +++ b/tests/phpunit/includes/jobqueue/jobs/ParsoidCachePrewarmJobTest.php @@ -1,5 +1,6 @@ <?php +use MediaWiki\Page\PageIdentity; use MediaWiki\Page\PageIdentityValue; use MediaWiki\Page\PageRecord; @@ -22,6 +23,11 @@ class ParsoidCachePrewarmJobTest extends MediaWikiIntegrationTestCase { ); } + private function getPageRecord( PageIdentity $page ): PageRecord { + return $this->getServiceContainer()->getPageStore() + ->getPageByReference( $page ); + } + /** * @covers \ParsoidCachePrewarmJob::doParsoidCacheUpdate * @covers \ParsoidCachePrewarmJob::newSpec @@ -33,7 +39,7 @@ class ParsoidCachePrewarmJobTest extends MediaWikiIntegrationTestCase { $parsoidPrewarmJob = new ParsoidCachePrewarmJob( [ 'revId' => $rev1->getId(), 'pageId' => $page->getId() ], - $this->getServiceContainer()->getParsoidOutputAccess(), + $this->getServiceContainer()->getParserOutputAccess(), $this->getServiceContainer()->getPageStore(), $this->getServiceContainer()->getRevisionLookup(), $this->getServiceContainer()->getParsoidSiteConfig() @@ -45,9 +51,11 @@ class ParsoidCachePrewarmJobTest extends MediaWikiIntegrationTestCase { $execStatus = $parsoidPrewarmJob->run(); $this->assertTrue( $execStatus ); - $parsoidOutput = $this->getServiceContainer()->getParsoidOutputAccess()->getCachedParserOutput( - $this->getPageIdentity( $page ), - ParserOptions::newFromAnon(), + $popts = ParserOptions::newFromAnon(); + $popts->setUseParsoid(); + $parsoidOutput = $this->getServiceContainer()->getParserOutputAccess()->getCachedParserOutput( + $this->getPageRecord( $this->getPageIdentity( $page ) ), + $popts, $rev1 ); @@ -59,12 +67,12 @@ class ParsoidCachePrewarmJobTest extends MediaWikiIntegrationTestCase { // Post-edit, reset all services! // ParserOutputAccess has a localCache which can incorrectly return stale // content for the previous revision! Resetting ensures that ParsoidCachePrewarmJob - // gets a fresh copy of ParserOutputAccess and ParsoidOutputAccess. + // gets a fresh copy of ParserOutputAccess. $this->resetServices(); $parsoidPrewarmJob = new ParsoidCachePrewarmJob( [ 'revId' => $rev2->getId(), 'pageId' => $page->getId(), 'causeAction' => 'just for testing' ], - $this->getServiceContainer()->getParsoidOutputAccess(), + $this->getServiceContainer()->getParserOutputAccess(), $this->getServiceContainer()->getPageStore(), $this->getServiceContainer()->getRevisionLookup(), $this->getServiceContainer()->getParsoidSiteConfig() @@ -83,9 +91,9 @@ class ParsoidCachePrewarmJobTest extends MediaWikiIntegrationTestCase { // At this point, we have 0 jobs scheduled for this job type. $this->assertSame( 0, $jobQueueGroup->getQueueSizes()['parsoidCachePrewarm'] ); - $parsoidOutput = $this->getServiceContainer()->getParsoidOutputAccess()->getCachedParserOutput( - $this->getPageIdentity( $page ), - ParserOptions::newFromAnon(), + $parsoidOutput = $this->getServiceContainer()->getParserOutputAccess()->getCachedParserOutput( + $this->getPageRecord( $this->getPageIdentity( $page ) ), + $popts, $rev2 ); |