Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7459458
OutreachTest.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
OutreachTest.php
View Options
<?php
use
MediaWiki\Config\HashConfig
;
use
MediaWiki\User\User
;
use
MobileFrontend\Amc\Manager
;
use
MobileFrontend\Amc\Outreach
;
use
MobileFrontend\Amc\UserMode
;
/**
* @coversDefaultClass \MobileFrontend\Amc\Outreach
* @group MobileFrontend
*/
class
OutreachTest
extends
MediaWikiUnitTestCase
{
/**
* @param bool $mfAmcOutreach
*
* @return Outreach
*/
private
function
createOutreach
(
bool
$mfAmcOutreach
):
Outreach
{
$userMode
=
$this
->
createNoOpMock
(
UserMode
::
class
,
[
'isEnabled'
]
);
$userMode
->
method
(
'isEnabled'
)->
willReturn
(
false
);
$mobileContext
=
$this
->
createNoOpMock
(
MobileContext
::
class
,
[
'shouldDisplayMobileView'
,
'getUser'
]
);
$mobileContext
->
method
(
'shouldDisplayMobileView'
)->
willReturn
(
true
);
$user
=
$this
->
createNoOpMock
(
User
::
class
,
[
'isAnon'
,
'getEditCount'
,
'isBot'
]
);
$user
->
method
(
'isAnon'
)->
willReturn
(
false
);
$user
->
method
(
'getEditCount'
)->
willReturn
(
0
);
$user
->
method
(
'isBot'
)->
willReturn
(
false
);
$mobileContext
->
method
(
'getUser'
)->
willReturn
(
$user
);
$amcManager
=
new
Manager
(
new
HashConfig
(
[
'MFAdvancedMobileContributions'
=>
true
]
),
$mobileContext
);
$config
=
new
HashConfig
(
[
'MFAmcOutreach'
=>
$mfAmcOutreach
,
'MFAmcOutreachMinEditCount'
=>
0
,
]
);
return
new
Outreach
(
$userMode
,
$amcManager
,
$user
,
$config
);
}
/** @return Generator */
public
static
function
provideIsCampaignActive
():
Generator
{
yield
'$mfAmcOutreach config enabled, expects campaign to be active'
=>
[
true
,
true
];
yield
'$mfAmcOutreach config disabled, expects campaign to be inactive'
=>
[
false
,
false
];
}
/**
* @covers ::__construct
* @covers ::isCampaignActive
* @dataProvider provideIsCampaignActive
*/
public
function
testIsCampaignActive
(
$mfAmcOutreach
,
$expected
)
{
$outreach
=
$this
->
createOutreach
(
$mfAmcOutreach
);
$this
->
assertSame
(
$expected
,
$outreach
->
isCampaignActive
()
);
}
/** @return Generator */
public
static
function
provideIsUserEligible
():
Generator
{
yield
'$mfAmcOutreach config enabled, user is eligible'
=>
[
true
,
true
];
yield
'$mfAmcOutreach config disabled, user is not eligible'
=>
[
false
,
false
];
}
/**
* @covers ::__construct
* @covers ::isUserEligible
* @dataProvider provideIsUserEligible
*/
public
function
testIsUserEligible
(
$mfAmcOutreach
,
$expected
)
{
$outreach
=
$this
->
createOutreach
(
$mfAmcOutreach
);
$this
->
assertSame
(
$expected
,
$outreach
->
isUserEligible
()
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Nov 23, 02:00 (2 d, 20 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
bf/6f/4e080359a370fb45ddf2fea18bc4
Default Alt Text
OutreachTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment