Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4119188
LogPageTest.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
LogPageTest.php
View Options
<?php
namespace
MediaWiki\Tests\Log
;
use
DatabaseLogEntry
;
use
LogPage
;
use
MediaWiki\MainConfigNames
;
use
MediaWiki\User\UserIdentityValue
;
use
MockTitleTrait
;
/**
* @group Database
* @coversDefaultClass \LogPage
*/
class
LogPageTest
extends
\MediaWikiIntegrationTestCase
{
use
MockTitleTrait
;
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
overrideConfigValues
(
[
MainConfigNames
::
LogNames
=>
[
'test_test'
=>
'testing-log-message'
],
MainConfigNames
::
LogHeaders
=>
[
'test_test'
=>
'testing-log-header'
],
MainConfigNames
::
LogRestrictions
=>
[
'test_test'
=>
'testing-log-restriction'
]
]
);
}
/**
* @covers ::__construct
* @covers ::getName
* @covers ::getDescription
* @covers ::getRestriction
* @covers ::isRestricted
*/
public
function
testConstruct
()
{
$logPage
=
new
LogPage
(
'test_test'
);
$this
->
assertSame
(
'testing-log-message'
,
$logPage
->
getName
()->
getKey
()
);
$this
->
assertSame
(
'testing-log-header'
,
$logPage
->
getDescription
()->
getKey
()
);
$this
->
assertSame
(
'testing-log-restriction'
,
$logPage
->
getRestriction
()
);
$this
->
assertTrue
(
$logPage
->
isRestricted
()
);
}
/**
* @covers ::addEntry
* @covers ::getComment
* @covers ::getRcComment
* @covers ::getRcCommentIRC
*/
public
function
testAddEntrySetsProperties
()
{
$logPage
=
new
LogPage
(
'test_test'
);
$user
=
new
UserIdentityValue
(
1
,
'Bar'
);
$logPage
->
addEntry
(
'test_action'
,
$this
->
makeMockTitle
(
__METHOD__
),
'testing_comment'
,
[
'param_one'
,
'param_two'
],
$user
);
$this
->
assertSame
(
'testing_comment'
,
$logPage
->
getComment
()
);
$this
->
assertStringContainsString
(
'testing_comment'
,
$logPage
->
getRcComment
()
);
$this
->
assertStringContainsString
(
'testing_comment'
,
$logPage
->
getRcCommentIRC
()
);
}
/**
* @covers ::addEntry
*/
public
function
testAddEntrySave
()
{
$logPage
=
new
LogPage
(
'test_test'
);
$user
=
new
UserIdentityValue
(
1
,
'Foo'
);
$title
=
$this
->
makeMockTitle
(
__METHOD__
);
$id
=
$logPage
->
addEntry
(
'test_action'
,
$title
,
'testing_comment'
,
[
'param_one'
,
'param_two'
],
$user
);
$savedLogEntry
=
DatabaseLogEntry
::
newFromId
(
$id
,
$this
->
getDb
()
);
$this
->
assertNotNull
(
$savedLogEntry
);
$this
->
assertSame
(
'test_test'
,
$savedLogEntry
->
getType
()
);
$this
->
assertSame
(
'test_action'
,
$savedLogEntry
->
getSubtype
()
);
$this
->
assertSame
(
'testing_comment'
,
$savedLogEntry
->
getComment
()
);
$this
->
assertArrayEquals
(
[
'param_one'
,
'param_two'
],
$savedLogEntry
->
getParameters
()
);
$this
->
assertTrue
(
$title
->
equals
(
$savedLogEntry
->
getTarget
()
)
);
$this
->
assertTrue
(
$user
->
equals
(
$savedLogEntry
->
getPerformerIdentity
()
)
);
}
/**
* @covers ::actionText
*/
public
function
testUnknownAction
()
{
$title
=
$this
->
makeMockTitle
(
'Test Title'
);
$text
=
LogPage
::
actionText
(
'unknown'
,
'action'
,
$title
,
null
,
[
'discarded'
]
);
$this
->
assertSame
(
'performed unknown action "unknown/action" on [[Test Title]]'
,
$text
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 03:12 (2 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
6f/0e/415c8982bff4e66bc29ab9173fc1
Default Alt Text
LogPageTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment