3 use MediaWiki\Page\PageProps
;
4 use MediaWiki\Title\Title
;
6 class WikiCategoryPageTest
extends MediaWikiLangTestCase
{
9 * @covers \WikiCategoryPage::isHidden
11 public function testHiddenCategory_PropertyNotSet() {
12 $title = Title
::makeTitle( NS_CATEGORY
, 'CategoryPage' );
13 $title->resetArticleID( 42 );
14 $categoryPage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title );
16 $pageProps = $this->createMock( PageProps
::class );
17 $pageProps->expects( $this->once() )
18 ->method( 'getProperties' )
19 ->with( $title, 'hiddencat' )
22 $this->setService( 'PageProps', $pageProps );
24 $this->assertFalse( $categoryPage->isHidden() );
27 public static function provideCategoryContent() {
35 * @dataProvider provideCategoryContent
36 * @covers \WikiCategoryPage::isHidden
38 public function testHiddenCategory_PropertyIsSet( $isHidden ) {
40 $categoryTitle = Title
::makeTitle( NS_CATEGORY
, 'CategoryPage' );
41 $categoryTitle->resetArticleID( $categoryPageID );
42 $categoryPage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $categoryTitle );
44 $pageProps = $this->createMock( PageProps
::class );
45 $pageProps->expects( $this->once() )
46 ->method( 'getProperties' )
47 ->with( $categoryTitle, 'hiddencat' )
48 ->willReturn( $isHidden ?
[ $categoryPageID => '' ] : [] );
50 $this->setService( 'PageProps', $pageProps );
52 $this->assertEquals( $isHidden, $categoryPage->isHidden() );
56 * @covers \WikiCategoryPage::isExpectedUnusedCategory
58 public function testExpectUnusedCategory_PropertyNotSet() {
59 $title = Title
::makeTitle( NS_CATEGORY
, 'CategoryPage' );
60 $title->resetArticleID( 42 );
61 $categoryPage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title );
63 $pageProps = $this->createMock( PageProps
::class );
64 $pageProps->expects( $this->once() )
65 ->method( 'getProperties' )
66 ->with( $title, 'expectunusedcategory' )
69 $this->setService( 'PageProps', $pageProps );
71 $this->assertFalse( $categoryPage->isExpectedUnusedCategory() );
75 * @dataProvider provideCategoryContent
76 * @covers \WikiCategoryPage::isExpectedUnusedCategory
78 public function testExpectUnusedCategory_PropertyIsSet( $isExpectedUnusedCategory ) {
80 $categoryTitle = Title
::makeTitle( NS_CATEGORY
, 'CategoryPage' );
81 $categoryTitle->resetArticleID( $categoryPageID );
82 $categoryPage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $categoryTitle );
83 $returnValue = $isExpectedUnusedCategory ?
[ $categoryPageID => '' ] : [];
85 $pageProps = $this->createMock( PageProps
::class );
86 $pageProps->expects( $this->once() )
87 ->method( 'getProperties' )
88 ->with( $categoryTitle, 'expectunusedcategory' )
89 ->willReturn( $returnValue );
91 $this->setService( 'PageProps', $pageProps );
93 $this->assertEquals( $isExpectedUnusedCategory, $categoryPage->isExpectedUnusedCategory() );