3 class WikiCategoryPageTest
extends MediaWikiLangTestCase
{
6 * @return PHPUnit_Framework_MockObject_MockObject|PageProps
8 private function getMockPageProps() {
9 return $this->getMockBuilder( PageProps
::class )
10 ->disableOriginalConstructor()
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() {
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 );