Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1427672
PermissionsErrorTest.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
PermissionsErrorTest.php
View Options
<?php
use
MediaWiki\Message\Message
;
use
MediaWiki\Permissions\PermissionStatus
;
use
Wikimedia\TestingAccessWrapper
;
/**
* @covers \PermissionsError
*/
class
PermissionsErrorTest
extends
MediaWikiIntegrationTestCase
{
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
setGroupPermissions
(
'*'
,
'testpermission'
,
true
);
}
public
static
function
provideConstruction
()
{
$status
=
new
PermissionStatus
();
$status
->
error
(
'cat'
,
1
,
2
);
$status
->
error
(
'dog'
,
3
,
4
);
$array
=
[
[
'cat'
,
1
,
2
],
[
'dog'
,
3
,
4
]
];
yield
[
null
,
$status
,
$status
];
yield
[
null
,
$array
,
$status
];
yield
[
'testpermission'
,
$status
,
$status
];
yield
[
'testpermission'
,
$array
,
$status
];
yield
[
'testpermission'
,
[],
PermissionStatus
::
newEmpty
()->
fatal
(
'badaccess-groups'
,
Message
::
listParam
(
[
'*'
],
'comma'
),
1
)
];
}
/**
* @dataProvider provideConstruction
*/
public
function
testConstruction
(
$permission
,
$errors
,
$expected
)
{
$e
=
new
PermissionsError
(
$permission
,
$errors
);
$et
=
TestingAccessWrapper
::
newFromObject
(
$e
);
$this
->
expectDeprecationAndContinue
(
'/Use of PermissionsError::
\\
$permission/'
);
$this
->
assertEquals
(
$permission
,
$e
->
permission
);
$this
->
assertStatusMessagesExactly
(
$expected
,
$et
->
status
);
$this
->
expectDeprecationAndContinue
(
'/Use of PermissionsError::
\\
$errors/'
);
$this
->
assertArrayEquals
(
$expected
->
toLegacyErrorArray
(),
$e
->
errors
);
// Test the deprecated public property setter
$e
->
errors
=
$e
->
errors
;
$this
->
assertStatusMessagesExactly
(
$expected
,
$et
->
status
);
}
public
static
function
provideInvalidConstruction
()
{
yield
[
null
,
null
];
yield
[
null
,
[]
];
yield
[
null
,
new
PermissionStatus
()
];
}
/**
* @dataProvider provideInvalidConstruction
*/
public
function
testInvalidConstruction
(
$permission
,
$errors
)
{
$this
->
expectException
(
InvalidArgumentException
::
class
);
$e
=
new
PermissionsError
(
$permission
,
$errors
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 14:57 (1 d, 5 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
81/e2/e7ab24edb853bdb69ec1d8a0a17c
Default Alt Text
PermissionsErrorTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment