mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-01 02:46:46 +00:00
1560528dc7
* Add a section on the preference form to allow users to mute articles from generating "page linked" notices * The preference will save the article title as an article ID Depends-On: Ia0ddf78646ec4c8ae0b84b6d5b46ef5e51c8e8c1 Bug: T46787 Change-Id: I67f751eae5fdc5bccff7fe3047227d432c1cb8d5
60 lines
1.1 KiB
PHP
60 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @coversDefaultClass EchoContainmentSet
|
|
*/
|
|
class EchoContainmentSetTest extends \MediaWikiUnitTestCase {
|
|
|
|
/**
|
|
* @covers ::addTitleIDsFromUserOption
|
|
* @dataProvider addTitlesFromUserOptionProvider
|
|
* @param User $user
|
|
* @param string $prefData
|
|
* @param string $contains
|
|
* @param bool $expected
|
|
*/
|
|
public function testAddTitlesFromUserOption(
|
|
$prefData, string $contains, bool $expected
|
|
) {
|
|
$user = $this->getDefaultUserMock();
|
|
$user->method( 'getOption' )
|
|
->willReturn( $prefData );
|
|
$containmentSet = new EchoContainmentSet( $user );
|
|
$containmentSet->addTitleIDsFromUserOption( 'preference-name' );
|
|
$this->assertSame( $expected, $containmentSet->contains( $contains ) );
|
|
}
|
|
|
|
public function addTitlesFromUserOptionProvider() :array {
|
|
return [
|
|
[
|
|
'foo',
|
|
'bar',
|
|
false
|
|
],
|
|
[
|
|
[ 'foo', 'bar' ],
|
|
'foo',
|
|
false
|
|
],
|
|
[
|
|
"foo\nbar",
|
|
'bar',
|
|
true
|
|
],
|
|
[
|
|
'{"foo":"bar"}',
|
|
'bar',
|
|
false
|
|
]
|
|
|
|
];
|
|
}
|
|
|
|
private function getDefaultUserMock() {
|
|
return $this->getMockBuilder( User::class )
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
}
|
|
|
|
}
|