MediaWiki  1.30.0
WikiCategoryPageTest.php
Go to the documentation of this file.
1 <?php
2 
3 use Wikimedia\ScopedCallback;
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 }
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
WikiCategoryPageTest\getMockPageProps
getMockPageProps()
Definition: WikiCategoryPageTest.php:10
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
WikiCategoryPageTest\testHiddenCategory_PropertyNotSet
testHiddenCategory_PropertyNotSet()
WikiCategoryPage::isHidden.
Definition: WikiCategoryPageTest.php:19
WikiCategoryPageTest
Definition: WikiCategoryPageTest.php:5
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:932
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:121
PageProps\overrideInstance
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
WikiCategoryPageTest\provideCategoryContent
provideCategoryContent()
Definition: WikiCategoryPageTest.php:36
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:529
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:79
WikiCategoryPageTest\testHiddenCategory_PropertyIsSet
testHiddenCategory_PropertyIsSet( $isHidden)
provideCategoryContent WikiCategoryPage::isHidden
Definition: WikiCategoryPageTest.php:47
MediaWikiLangTestCase
Base class that store and restore the Language objects.
Definition: MediaWikiLangTestCase.php:6
true
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:1965
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52