MediaWiki REL1_33
WikiCategoryPageTest.php
Go to the documentation of this file.
1<?php
2
4
6
10 private function getMockPageProps() {
11 return $this->getMockBuilder( PageProps::class )
12 ->disableOriginalConstructor()
13 ->getMock();
14 }
15
20 $title = Title::makeTitle( NS_CATEGORY, 'CategoryPage' );
21 $categoryPage = WikiCategoryPage::factory( $title );
22
23 $pageProps = $this->getMockPageProps();
24 $pageProps->expects( $this->once() )
25 ->method( 'getProperties' )
26 ->with( $title, 'hiddencat' )
27 ->will( $this->returnValue( [] ) );
28
29 $scopedOverride = PageProps::overrideInstance( $pageProps );
30
31 $this->assertFalse( $categoryPage->isHidden() );
32
33 ScopedCallback::consume( $scopedOverride );
34 }
35
36 public function provideCategoryContent() {
37 return [
38 [ true ],
39 [ false ],
40 ];
41 }
42
47 public function testHiddenCategory_PropertyIsSet( $isHidden ) {
48 $categoryTitle = Title::makeTitle( NS_CATEGORY, 'CategoryPage' );
49 $categoryPage = WikiCategoryPage::factory( $categoryTitle );
50
51 $pageProps = $this->getMockPageProps();
52 $pageProps->expects( $this->once() )
53 ->method( 'getProperties' )
54 ->with( $categoryTitle, 'hiddencat' )
55 ->will( $this->returnValue( $isHidden ? [ $categoryTitle->getArticleID() => '' ] : [] ) );
56
57 $scopedOverride = PageProps::overrideInstance( $pageProps );
58
59 $this->assertEquals( $isHidden, $categoryPage->isHidden() );
60
61 ScopedCallback::consume( $scopedOverride );
62 }
63
68 $title = Title::makeTitle( NS_CATEGORY, 'CategoryPage' );
69 $categoryPage = WikiCategoryPage::factory( $title );
70
71 $pageProps = $this->getMockPageProps();
72 $pageProps->expects( $this->once() )
73 ->method( 'getProperties' )
74 ->with( $title, 'expectunusedcategory' )
75 ->will( $this->returnValue( [] ) );
76
77 $scopedOverride = PageProps::overrideInstance( $pageProps );
78
79 $this->assertFalse( $categoryPage->isExpectedUnusedCategory() );
80
81 ScopedCallback::consume( $scopedOverride );
82 }
83
88 public function testExpectUnusedCategory_PropertyIsSet( $isExpectedUnusedCategory ) {
89 $categoryTitle = Title::makeTitle( NS_CATEGORY, 'CategoryPage' );
90 $categoryPage = WikiCategoryPage::factory( $categoryTitle );
91 $returnValue = $isExpectedUnusedCategory ? [ $categoryTitle->getArticleID() => '' ] : [];
92
93 $pageProps = $this->getMockPageProps();
94 $pageProps->expects( $this->once() )
95 ->method( 'getProperties' )
96 ->with( $categoryTitle, 'expectunusedcategory' )
97 ->will( $this->returnValue( $returnValue ) );
98
99 $scopedOverride = PageProps::overrideInstance( $pageProps );
100
101 $this->assertEquals( $isExpectedUnusedCategory, $categoryPage->isExpectedUnusedCategory() );
102
103 ScopedCallback::consume( $scopedOverride );
104 }
105}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Base class that store and restore the Language objects.
static overrideInstance(PageProps $store=null)
Overrides the default instance of this class This is intended for use while testing and will fail if ...
Definition PageProps.php:50
testHiddenCategory_PropertyIsSet( $isHidden)
provideCategoryContent WikiCategoryPage::isHidden
testExpectUnusedCategory_PropertyIsSet( $isExpectedUnusedCategory)
provideCategoryContent WikiCategoryPage::isExpectedUnusedCategory
testExpectUnusedCategory_PropertyNotSet()
WikiCategoryPage::isExpectedUnusedCategory.
testHiddenCategory_PropertyNotSet()
WikiCategoryPage::isHidden.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition WikiPage.php:138
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition hooks.txt:2004
processing should stop and the error should be shown to the user * false
Definition hooks.txt:187
const NS_CATEGORY
Definition Defines.php:87