Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4144168
AuthenticationRequestTestCase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
AuthenticationRequestTestCase.php
View Options
<?php
namespace
MediaWiki\Tests\Auth
;
use
MediaWiki\Auth\AuthenticationRequest
;
use
MediaWiki\Message\Message
;
use
MediaWikiIntegrationTestCase
;
use
ReflectionMethod
;
use
const
E_USER_DEPRECATED
;
/**
* @group AuthManager
*/
abstract
class
AuthenticationRequestTestCase
extends
MediaWikiIntegrationTestCase
{
/**
* @param array $args
*
* @return AuthenticationRequest
*/
abstract
protected
function
getInstance
(
array
$args
=
[]
);
/**
* @dataProvider provideGetFieldInfo
*/
public
function
testGetFieldInfo
(
array
$args
)
{
$info
=
$this
->
getInstance
(
$args
)->
getFieldInfo
();
$this
->
assertIsArray
(
$info
);
foreach
(
$info
as
$field
=>
$data
)
{
$this
->
assertIsArray
(
$data
,
"Field $field"
);
$this
->
assertArrayHasKey
(
'type'
,
$data
,
"Field $field"
);
$this
->
assertArrayHasKey
(
'label'
,
$data
,
"Field $field"
);
$this
->
assertInstanceOf
(
Message
::
class
,
$data
[
'label'
],
"Field $field, label"
);
if
(
$data
[
'type'
]
!==
'null'
)
{
$this
->
assertArrayHasKey
(
'help'
,
$data
,
"Field $field"
);
$this
->
assertInstanceOf
(
Message
::
class
,
$data
[
'help'
],
"Field $field, help"
);
}
if
(
isset
(
$data
[
'optional'
]
)
)
{
$this
->
assertIsBool
(
$data
[
'optional'
],
"Field $field, optional"
);
}
if
(
isset
(
$data
[
'image'
]
)
)
{
$this
->
assertIsString
(
$data
[
'image'
],
"Field $field, image"
);
}
if
(
isset
(
$data
[
'sensitive'
]
)
)
{
$this
->
assertIsBool
(
$data
[
'sensitive'
],
"Field $field, sensitive"
);
}
if
(
$data
[
'type'
]
===
'password'
)
{
$this
->
assertTrue
(
!
empty
(
$data
[
'sensitive'
]
),
"Field $field, password field must be sensitive"
);
}
switch
(
$data
[
'type'
]
)
{
case
'string'
:
case
'password'
:
case
'hidden'
:
break
;
case
'select'
:
case
'multiselect'
:
$this
->
assertArrayHasKey
(
'options'
,
$data
,
"Field $field"
);
$this
->
assertIsArray
(
$data
[
'options'
],
"Field $field, options"
);
foreach
(
$data
[
'options'
]
as
$val
=>
$msg
)
{
$this
->
assertInstanceOf
(
Message
::
class
,
$msg
,
"Field $field, option $val"
);
}
break
;
case
'checkbox'
:
break
;
case
'button'
:
break
;
case
'null'
:
break
;
default
:
$this
->
fail
(
"Field $field, unknown type "
.
$data
[
'type'
]
);
break
;
}
}
}
public
static
function
provideGetFieldInfo
()
{
return
[
[
[]
]
];
}
/**
* @dataProvider provideLoadFromSubmissionStatically
* @param array $args
* @param array $data
* @param array|bool $expectState
*/
public
function
testLoadFromSubmission
(
array
$args
,
array
$data
,
$expectState
)
{
$instance
=
$this
->
getInstance
(
$args
);
$ret
=
$instance
->
loadFromSubmission
(
$data
);
if
(
is_array
(
$expectState
)
)
{
$this
->
assertTrue
(
$ret
);
$expect
=
$instance
::
__set_state
(
$expectState
);
$this
->
assertEquals
(
$expect
,
$instance
);
}
else
{
$this
->
assertFalse
(
$ret
);
}
}
// abstract public static function provideLoadFromSubmission();
/**
* Tempory override to make provideLoadFromSubmission static.
* See T332865.
*/
final
public
static
function
provideLoadFromSubmissionStatically
()
{
$reflectionMethod
=
new
ReflectionMethod
(
static
::
class
,
'provideLoadFromSubmission'
);
if
(
$reflectionMethod
->
isStatic
()
)
{
return
$reflectionMethod
->
invoke
(
null
);
}
trigger_error
(
'overriding provideLoadFromSubmission as an instance method is deprecated. ('
.
$reflectionMethod
->
getFileName
()
.
':'
.
$reflectionMethod
->
getEndLine
()
.
')'
,
E_USER_DEPRECATED
);
return
$reflectionMethod
->
invoke
(
new
static
()
);
}
}
/** @deprecated class alias since 1.42 */
class_alias
(
AuthenticationRequestTestCase
::
class
,
'MediaWiki
\\
Auth
\\
AuthenticationRequestTestCase'
);
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 19 2026, 17:07 (4 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f1/60/2af7c1bff8c10aec280ea905c8c4
Default Alt Text
AuthenticationRequestTestCase.php (3 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment