API: Fixes for AuthManager
[mediawiki.git] / tests / phpunit / includes / page / WikiCategoryPageTest.php
blob9f4e1fabbbeae42db46d836f72b4fb99ba0e7193
1 <?php
3 class WikiCategoryPageTest extends MediaWikiLangTestCase {
5 /**
6 * @return PHPUnit_Framework_MockObject_MockObject|PageProps
7 */
8 private function getMockPageProps() {
9 return $this->getMockBuilder( PageProps::class )
10 ->disableOriginalConstructor()
11 ->getMock();
14 /**
15 * @covers WikiCategoryPage::isHidden
17 public function testHiddenCategory_PropertyNotSet() {
18 $title = Title::makeTitle( NS_CATEGORY, 'CategoryPage' );
19 $categoryPage = WikiCategoryPage::factory( $title );
21 $pageProps = $this->getMockPageProps();
22 $pageProps->expects( $this->once() )
23 ->method( 'getProperties' )
24 ->with( $title, 'hiddencat' )
25 ->will( $this->returnValue( [] ) );
27 $scopedOverride = PageProps::overrideInstance( $pageProps );
29 $this->assertFalse( $categoryPage->isHidden() );
31 ScopedCallback::consume( $scopedOverride );
34 public function provideCategoryContent() {
35 return [
36 [ true ],
37 [ false ],
41 /**
42 * @dataProvider provideCategoryContent
43 * @covers WikiCategoryPage::isHidden
45 public function testHiddenCategory_PropertyIsSet( $isHidden ) {
46 $categoryTitle = Title::makeTitle( NS_CATEGORY, 'CategoryPage' );
47 $categoryPage = WikiCategoryPage::factory( $categoryTitle );
49 $pageProps = $this->getMockPageProps();
50 $pageProps->expects( $this->once() )
51 ->method( 'getProperties' )
52 ->with( $categoryTitle, 'hiddencat' )
53 ->will( $this->returnValue( $isHidden ? [ $categoryTitle->getArticleID() => '' ] : [] ) );
55 $scopedOverride = PageProps::overrideInstance( $pageProps );
57 $this->assertEquals( $isHidden, $categoryPage->isHidden() );
59 ScopedCallback::consume( $scopedOverride );