Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4088447
RestrictionTestCase.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
RestrictionTestCase.php
View Options
<?php
namespace
MediaWiki\Tests\Block\Restriction
;
/**
* @group Blocking
*/
abstract
class
RestrictionTestCase
extends
\MediaWikiIntegrationTestCase
{
public
function
testConstruct
()
{
$class
=
$this
->
getClass
();
$restriction
=
new
$class
(
1
,
2
);
$this
->
assertSame
(
1
,
$restriction
->
getBlockId
()
);
$this
->
assertSame
(
2
,
$restriction
->
getValue
()
);
}
public
function
testSetBlockId
()
{
$class
=
$this
->
getClass
();
$restriction
=
new
$class
(
1
,
2
);
$restriction
->
setBlockId
(
10
);
$this
->
assertSame
(
10
,
$restriction
->
getBlockId
()
);
}
public
function
testEquals
()
{
$class
=
$this
->
getClass
();
// Test two restrictions with the same data.
$restriction
=
new
$class
(
1
,
2
);
$second
=
new
$class
(
1
,
2
);
$this
->
assertTrue
(
$restriction
->
equals
(
$second
)
);
// Test two restrictions that implement different classes.
$second
=
$this
->
createMock
(
$this
->
getClass
()
);
$this
->
assertFalse
(
$restriction
->
equals
(
$second
)
);
// Not the same block id.
$second
=
new
$class
(
2
,
2
);
$this
->
assertTrue
(
$restriction
->
equals
(
$second
)
);
// Not the same value.
$second
=
new
$class
(
1
,
3
);
$this
->
assertFalse
(
$restriction
->
equals
(
$second
)
);
}
public
function
testNewFromRow
()
{
$class
=
$this
->
getClass
();
$restriction
=
$class
::
newFromRow
(
(
object
)[
'ir_ipb_id'
=>
1
,
'ir_value'
=>
2
,
]
);
$this
->
assertSame
(
1
,
$restriction
->
getBlockId
()
);
$this
->
assertSame
(
2
,
$restriction
->
getValue
()
);
}
public
function
testToRow
()
{
$class
=
$this
->
getClass
();
$restriction
=
new
$class
(
1
,
2
);
$row
=
$restriction
->
toRow
();
$this
->
assertSame
(
1
,
$row
[
'ir_ipb_id'
]
);
$this
->
assertSame
(
2
,
$row
[
'ir_value'
]
);
}
/**
* Get the class name of the class that is being tested.
*
* @return string
*/
abstract
protected
function
getClass
();
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 18 2026, 09:59 (6 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
6c/20/4ab06dcd4cc3de8126a96d819375
Default Alt Text
RestrictionTestCase.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment