Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5979239
DeprecatablePropertyArrayTest.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
DeprecatablePropertyArrayTest.php
View Options
<?php
use
MediaWiki\Debug\DeprecatablePropertyArray
;
/**
* @covers \MediaWiki\Debug\DeprecatablePropertyArray
*/
class
DeprecatablePropertyArrayTest
extends
MediaWikiUnitTestCase
{
private
const
PROP_NAME
=
'test_property'
;
/**
* @dataProvider provideDeprecationWarning
*/
public
function
testDeprecationWarning
(
callable
$callback
,
string
$message
)
{
$this
->
expectDeprecationAndContinue
(
'/'
.
preg_quote
(
$message
,
'/'
)
.
'/'
);
$callback
();
}
public
function
provideDeprecationWarning
()
{
$propName
=
self
::
PROP_NAME
;
$array
=
new
DeprecatablePropertyArray
(
[
self
::
PROP_NAME
=>
'test_value'
,
'callback'
=>
static
function
()
{
return
'callback_test_value'
;
},
],
[
self
::
PROP_NAME
=>
'DEPRECATED_VERSION'
,
'callback'
=>
'DEPRECATED_VERSION'
,
],
'TEST'
);
yield
'get'
=>
[
function
()
use
(
$array
)
{
$this
->
assertSame
(
'test_value'
,
$array
[
self
::
PROP_NAME
]
);
},
"TEST get '{$propName}'"
];
yield
'get, callback'
=>
[
function
()
use
(
$array
)
{
$this
->
assertSame
(
'callback_test_value'
,
$array
[
'callback'
]
);
},
"TEST get 'callback'"
];
yield
'exists'
=>
[
function
()
use
(
$array
)
{
$this
->
assertTrue
(
isset
(
$array
[
self
::
PROP_NAME
]
)
);
},
"TEST exists '{$propName}'"
];
yield
'unset'
=>
[
static
function
()
use
(
$array
)
{
unset
(
$array
[
self
::
PROP_NAME
]
);
},
"TEST unset '{$propName}'"
];
}
public
function
testNonDeprecated
()
{
$array
=
new
DeprecatablePropertyArray
(
[],
[],
__METHOD__
);
$this
->
assertFalse
(
isset
(
$array
[
self
::
PROP_NAME
]
)
);
$array
[
self
::
PROP_NAME
]
=
'test_value'
;
$this
->
assertTrue
(
isset
(
$array
[
self
::
PROP_NAME
]
)
);
$this
->
assertSame
(
'test_value'
,
$array
[
self
::
PROP_NAME
]
);
unset
(
$array
[
self
::
PROP_NAME
]
);
$this
->
assertFalse
(
isset
(
$array
[
self
::
PROP_NAME
]
)
);
}
public
function
testNonDeprecatedNumerical
()
{
$array
=
new
DeprecatablePropertyArray
(
[],
[],
__METHOD__
);
$this
->
assertFalse
(
isset
(
$array
[
0
]
)
);
$array
[]
=
'test_value'
;
$this
->
assertTrue
(
isset
(
$array
[
0
]
)
);
$this
->
assertSame
(
'test_value'
,
$array
[
0
]
);
unset
(
$array
[
0
]
);
$this
->
assertFalse
(
isset
(
$array
[
0
]
)
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 20:49 (4 d, 10 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
15/f8/99e9cff36ff6a72a1824d7c80fc8
Default Alt Text
DeprecatablePropertyArrayTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment