Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7414822
WorkflowTest.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
WorkflowTest.php
View Options
<?php
namespace
MediaWiki\Extension\OAuth\Tests\Control
;
use
MediaWiki\Config\HashConfig
;
use
MediaWiki\Config\ServiceOptions
;
use
MediaWiki\Extension\OAuth\Backend\Consumer
;
use
MediaWiki\Extension\OAuth\Control\Workflow
;
use
MediaWikiUnitTestCase
;
/**
* @covers \MediaWiki\Extension\OAuth\Control\Workflow
*/
class
WorkflowTest
extends
MediaWikiUnitTestCase
{
/**
* @dataProvider provideConsumerCanBeAutoApproved
*/
public
function
testConsumerCanBeAutoApproved
(
array
$oauthAutoApprove
,
array
$consumerGrants
,
bool
$expectedResult
)
{
$config
=
new
HashConfig
(
[
'OAuthAutoApprove'
=>
$oauthAutoApprove
]
);
$consumer
=
$this
->
createNoOpMock
(
Consumer
::
class
,
[
'getGrants'
]
);
$consumer
->
method
(
'getGrants'
)->
willReturn
(
$consumerGrants
);
$workflow
=
new
Workflow
(
new
ServiceOptions
(
Workflow
::
CONSTRUCTOR_OPTIONS
,
$config
)
);
$this
->
assertSame
(
$expectedResult
,
$workflow
->
consumerCanBeAutoApproved
(
$consumer
)
);
}
public
static
function
provideConsumerCanBeAutoApproved
()
{
return
[
'empty'
=>
[
[],
[
'basic'
],
false
],
'good grants'
=>
[
[
[
'grants'
=>
[
'basic'
,
'editpage'
]
]
],
[
'basic'
],
true
],
'bad grants'
=>
[
[
[
'grants'
=>
[
'basic'
,
'editpage'
]
]
],
[
'import'
],
false
],
'good and bad grants'
=>
[
[
[
'grants'
=>
[
'basic'
,
'editpage'
]
]
],
[
'basic'
,
'import'
],
false
],
'multiple conditions 1'
=>
[
[
[
'grants'
=>
[
'basic'
,
'editpage'
]
],
[
'grants'
=>
[
'import'
]
],
],
[
'import'
],
true
],
'multiple conditions 2'
=>
[
[
[
'grants'
=>
[
'basic'
,
'editpage'
]
],
[
'grants'
=>
[
'import'
]
],
],
[
'basic'
,
'editpage'
,
'import'
],
false
],
'unknown rule'
=>
[
[
[
'grants'
=>
[
'basic'
,
'editpage'
],
'unknown'
=>
true
,
]
],
[
'basic'
],
false
],
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 22, 01:50 (1 d, 14 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ca/02/848c0056f2d7414b78c6643a317e
Default Alt Text
WorkflowTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment