Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4107720
WikiCategoryPageTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
WikiCategoryPageTest.php
View Options
<?php
use
MediaWiki\Page\PageProps
;
use
MediaWiki\Title\Title
;
class
WikiCategoryPageTest
extends
MediaWikiLangTestCase
{
/**
* @covers \WikiCategoryPage::isHidden
*/
public
function
testHiddenCategory_PropertyNotSet
()
{
$title
=
Title
::
makeTitle
(
NS_CATEGORY
,
'CategoryPage'
);
$title
->
resetArticleID
(
42
);
$categoryPage
=
$this
->
getServiceContainer
()->
getWikiPageFactory
()->
newFromTitle
(
$title
);
$pageProps
=
$this
->
createMock
(
PageProps
::
class
);
$pageProps
->
expects
(
$this
->
once
()
)
->
method
(
'getProperties'
)
->
with
(
$title
,
'hiddencat'
)
->
willReturn
(
[]
);
$this
->
setService
(
'PageProps'
,
$pageProps
);
$this
->
assertFalse
(
$categoryPage
->
isHidden
()
);
}
public
static
function
provideCategoryContent
()
{
return
[
[
true
],
[
false
],
];
}
/**
* @dataProvider provideCategoryContent
* @covers \WikiCategoryPage::isHidden
*/
public
function
testHiddenCategory_PropertyIsSet
(
$isHidden
)
{
$categoryPageID
=
42
;
$categoryTitle
=
Title
::
makeTitle
(
NS_CATEGORY
,
'CategoryPage'
);
$categoryTitle
->
resetArticleID
(
$categoryPageID
);
$categoryPage
=
$this
->
getServiceContainer
()->
getWikiPageFactory
()->
newFromTitle
(
$categoryTitle
);
$pageProps
=
$this
->
createMock
(
PageProps
::
class
);
$pageProps
->
expects
(
$this
->
once
()
)
->
method
(
'getProperties'
)
->
with
(
$categoryTitle
,
'hiddencat'
)
->
willReturn
(
$isHidden
?
[
$categoryPageID
=>
''
]
:
[]
);
$this
->
setService
(
'PageProps'
,
$pageProps
);
$this
->
assertEquals
(
$isHidden
,
$categoryPage
->
isHidden
()
);
}
/**
* @covers \WikiCategoryPage::isExpectedUnusedCategory
*/
public
function
testExpectUnusedCategory_PropertyNotSet
()
{
$title
=
Title
::
makeTitle
(
NS_CATEGORY
,
'CategoryPage'
);
$title
->
resetArticleID
(
42
);
$categoryPage
=
$this
->
getServiceContainer
()->
getWikiPageFactory
()->
newFromTitle
(
$title
);
$pageProps
=
$this
->
createMock
(
PageProps
::
class
);
$pageProps
->
expects
(
$this
->
once
()
)
->
method
(
'getProperties'
)
->
with
(
$title
,
'expectunusedcategory'
)
->
willReturn
(
[]
);
$this
->
setService
(
'PageProps'
,
$pageProps
);
$this
->
assertFalse
(
$categoryPage
->
isExpectedUnusedCategory
()
);
}
/**
* @dataProvider provideCategoryContent
* @covers \WikiCategoryPage::isExpectedUnusedCategory
*/
public
function
testExpectUnusedCategory_PropertyIsSet
(
$isExpectedUnusedCategory
)
{
$categoryPageID
=
42
;
$categoryTitle
=
Title
::
makeTitle
(
NS_CATEGORY
,
'CategoryPage'
);
$categoryTitle
->
resetArticleID
(
$categoryPageID
);
$categoryPage
=
$this
->
getServiceContainer
()->
getWikiPageFactory
()->
newFromTitle
(
$categoryTitle
);
$returnValue
=
$isExpectedUnusedCategory
?
[
$categoryPageID
=>
''
]
:
[];
$pageProps
=
$this
->
createMock
(
PageProps
::
class
);
$pageProps
->
expects
(
$this
->
once
()
)
->
method
(
'getProperties'
)
->
with
(
$categoryTitle
,
'expectunusedcategory'
)
->
willReturn
(
$returnValue
);
$this
->
setService
(
'PageProps'
,
$pageProps
);
$this
->
assertEquals
(
$isExpectedUnusedCategory
,
$categoryPage
->
isExpectedUnusedCategory
()
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Aug 18, 20:11 (2 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
40/1a/05acb30bcbcaaca1ecc5b6178c7b
Default Alt Text
WikiCategoryPageTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment