Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / page / WikiCategoryPageTest.php
blob4dee15e288c1ddb4b8ed15c509e1f5011ed32f8c
1 <?php
3 use MediaWiki\Page\PageProps;
4 use MediaWiki\Title\Title;
6 class WikiCategoryPageTest extends MediaWikiLangTestCase {
8 /**
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' )
20 ->willReturn( [] );
22 $this->setService( 'PageProps', $pageProps );
24 $this->assertFalse( $categoryPage->isHidden() );
27 public static function provideCategoryContent() {
28 return [
29 [ true ],
30 [ false ],
34 /**
35 * @dataProvider provideCategoryContent
36 * @covers \WikiCategoryPage::isHidden
38 public function testHiddenCategory_PropertyIsSet( $isHidden ) {
39 $categoryPageID = 42;
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() );
55 /**
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' )
67 ->willReturn( [] );
69 $this->setService( 'PageProps', $pageProps );
71 $this->assertFalse( $categoryPage->isExpectedUnusedCategory() );
74 /**
75 * @dataProvider provideCategoryContent
76 * @covers \WikiCategoryPage::isExpectedUnusedCategory
78 public function testExpectUnusedCategory_PropertyIsSet( $isExpectedUnusedCategory ) {
79 $categoryPageID = 42;
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() );