Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5983303
ParserObserverTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ParserObserverTest.php
View Options
<?php
namespace
MediaWiki\Tests\Parser
;
use
DummyContentForTesting
;
use
MediaWiki\Parser\ParserObserver
;
use
MediaWiki\Parser\ParserOptions
;
use
MediaWiki\Parser\ParserOutput
;
use
MediaWiki\Title\Title
;
use
MediaWikiUnitTestCase
;
use
TestLogger
;
/**
* @covers \MediaWiki\Parser\ParserObserver
*/
class
ParserObserverTest
extends
MediaWikiUnitTestCase
{
/**
* @param string $hashOne
* @param string $hashTwo
* @param array $expects
*
* @dataProvider provideDuplicateParse
*/
public
function
testDuplicateParse
(
string
$hashOne
,
string
$hashTwo
,
array
$expects
)
{
$logger
=
new
TestLogger
(
true
);
// ::makeTitle allows us to create a title without needing any services
$title
=
Title
::
makeTitle
(
NS_PROJECT
,
'Duplicate Parse Test'
);
$options
=
$this
->
createNoOpMock
(
ParserOptions
::
class
,
[
'optionsHash'
]
);
$options
->
method
(
'optionsHash'
)->
willReturnOnConsecutiveCalls
(
$hashOne
,
$hashTwo
);
$content
=
new
DummyContentForTesting
(
"hello world"
);
$output
=
new
ParserOutput
();
$observer
=
new
ParserObserver
(
$logger
);
$observer
->
notifyParse
(
$title
,
null
,
$options
,
$content
,
$output
);
$observer
->
notifyParse
(
$title
,
null
,
$options
,
$content
,
$output
);
$this
->
assertArrayEquals
(
$expects
,
$logger
->
getBuffer
()
);
}
public
static
function
provideDuplicateParse
()
{
yield
[
'foo'
,
'bar'
,
[]
];
yield
[
'foo'
,
'foo'
,
[
[
'debug'
,
'MediaWiki
\P
arser
\P
arserObserver::notifyParse: Possibly redundant parse!'
]
]
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 22:48 (1 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0f/09/16ed2479491e706579d78aacde5c
Default Alt Text
ParserObserverTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment