X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FStorage%2FDerivedPageDataUpdaterTest.php;h=c64169fd8c22724986de98deea3dc83b9da1d2f8;hb=825d66bfa44c5dae2b78e2fe4f3b16f16aff4a12;hp=cd19cca81a66437e3e28203746d9e7c93ea59e4d;hpb=2a710e256f86cacd5b6bf93afd7111556935bd15;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php b/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php index cd19cca81a..c64169fd8c 100644 --- a/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php +++ b/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php @@ -874,6 +874,92 @@ class DerivedPageDataUpdaterTest extends MediaWikiTestCase { ); } + /** + * * @covers \MediaWiki\Storage\DerivedPageDataUpdater::isCountable + */ + public function testIsCountableNotContentPage() { + $updater = $this->getDerivedPageDataUpdater( + Title::newFromText( 'Main_Page', NS_TALK ) + ); + self::assertFalse( $updater->isCountable() ); + } + + public function provideIsCountable() { + yield 'deleted revision' => [ + '$articleCountMethod' => 'any', + '$wikitextContent' => 'Test', + '$revisionVisibility' => RevisionRecord::SUPPRESSED_ALL, + '$isCountable' => false + ]; + yield 'redirect' => [ + '$articleCountMethod' => 'any', + '$wikitextContent' => '#REDIRECT [[Main_Page]]', + '$revisionVisibility' => 0, + '$isCountable' => false + ]; + yield 'no links count method any' => [ + '$articleCountMethod' => 'any', + '$wikitextContent' => 'Test', + '$revisionVisibility' => 0, + '$isCountable' => true + ]; + yield 'no links count method link' => [ + '$articleCountMethod' => 'link', + '$wikitextContent' => 'Test', + '$revisionVisibility' => 0, + '$isCountable' => false + ]; + yield 'with links count method link' => [ + '$articleCountMethod' => 'link', + '$wikitextContent' => '[[Test]]', + '$revisionVisibility' => 0, + '$isCountable' => true + ]; + } + + /** + * @dataProvider provideIsCountable + * + * @param string $articleCountMethod + * @param string $wikitextContent + * @param int $revisionVisibility + * @param bool $isCountable + * @throws \MWException + * @covers \MediaWiki\Storage\DerivedPageDataUpdater::isCountable + */ + public function testIsCountable( + $articleCountMethod, + $wikitextContent, + $revisionVisibility, + $isCountable + ) { + $this->setMwGlobals( [ 'wgArticleCountMethod' => $articleCountMethod ] ); + $title = $this->getTitle( 'Main_Page' ); + $content = new WikitextContent( $wikitextContent ); + $update = new RevisionSlotsUpdate(); + $update->modifyContent( SlotRecord::MAIN, $content ); + $revision = $this->makeRevision( $title, $update, User::newFromName( 'Alice' ), 'rev1', 13 ); + $revision->setVisibility( $revisionVisibility ); + $updater = $this->getDerivedPageDataUpdater( $title ); + $updater->prepareUpdate( $revision ); + self::assertSame( $isCountable, $updater->isCountable() ); + } + + /** + * @throws \MWException + * @covers \MediaWiki\Storage\DerivedPageDataUpdater::isCountable + */ + public function testIsCountableNoModifiedSlots() { + $page = $this->getPage( __METHOD__ ); + $content = [ 'main' => new WikitextContent( '[[Test]]' ) ]; + $rev = $this->createRevision( $page, 'first', $content ); + $nullRevision = MutableRevisionRecord::newFromParentRevision( $rev ); + $nullRevision->setId( 14 ); + $updater = $this->getDerivedPageDataUpdater( $page, $nullRevision ); + $updater->prepareUpdate( $nullRevision ); + $this->assertTrue( $updater->isCountable() ); + } + /** * @covers \MediaWiki\Storage\DerivedPageDataUpdater::doUpdates() * @covers \MediaWiki\Storage\DerivedPageDataUpdater::doSecondaryDataUpdates() @@ -976,7 +1062,7 @@ class DerivedPageDataUpdaterTest extends MediaWikiTestCase { $this->db->endAtomic( __METHOD__ ); // run deferred updates - $this->assertEquals( 0, DeferredUpdates::pendingUpdatesCount(), 'No pending updates' ); + $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount(), 'No pending updates' ); } /** @@ -1009,7 +1095,7 @@ class DerivedPageDataUpdaterTest extends MediaWikiTestCase { $this->db->endAtomic( __METHOD__ ); // run deferred updates - $this->assertEquals( 0, DeferredUpdates::pendingUpdatesCount(), 'No pending updates' ); + $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount(), 'No pending updates' ); $this->assertNotFalse( $pcache->get( $page, $updater->getCanonicalParserOptions() ) ); }