X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fchanges%2FRecentChangeTest.php;h=45f1382c47b49f5e104104c5af8edf36a7c6f61e;hb=6164423de0f34b5c264bacebb8371811e07fdaa8;hp=4abe9eef6ae6d4b6c4b452468e81310bda59a2c8;hpb=a85d1b9d0cd7f02111d3a647d5b91e3b1f334563;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/changes/RecentChangeTest.php b/tests/phpunit/includes/changes/RecentChangeTest.php index 4abe9eef6a..45f1382c47 100644 --- a/tests/phpunit/includes/changes/RecentChangeTest.php +++ b/tests/phpunit/includes/changes/RecentChangeTest.php @@ -134,4 +134,51 @@ class RecentChangeTest extends MediaWikiTestCase { $this->assertEquals( $rcType, RecentChange::parseToRCType( $type ) ); } + /** + * @return PHPUnit_Framework_MockObject_MockObject|PageProps + */ + private function getMockPageProps() { + return $this->getMockBuilder( PageProps::class ) + ->disableOriginalConstructor() + ->getMock(); + } + + public function provideCategoryContent() { + return [ + [ true ], + [ false ], + ]; + } + + /** + * @dataProvider provideCategoryContent + * @covers RecentChange::newForCategorization + */ + public function testHiddenCategoryChange( $isHidden ) { + $categoryTitle = Title::newFromText( 'CategoryPage', NS_CATEGORY ); + + $pageProps = $this->getMockPageProps(); + $pageProps->expects( $this->once() ) + ->method( 'getProperties' ) + ->with( $categoryTitle, 'hiddencat' ) + ->will( $this->returnValue( $isHidden ? [ $categoryTitle->getArticleID() => '' ] : [] ) ); + + $scopedOverride = PageProps::overrideInstance( $pageProps ); + + $rc = RecentChange::newForCategorization( + '0', + $categoryTitle, + $this->user, + $this->user_comment, + $this->title, + $categoryTitle->getLatestRevID(), + $categoryTitle->getLatestRevID(), + '0', + false + ); + + $this->assertEquals( $isHidden, $rc->getParam( 'hidden-cat' ) ); + + ScopedCallback::consume( $scopedOverride ); + } }