Update mediawiki/mediawiki-codesniffer to 0.7.1
[lhc/web/wiklou.git] / tests / phpunit / includes / changes / RecentChangeTest.php
index 4abe9ee..45f1382 100644 (file)
@@ -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 );
+       }
 }