mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-18 02:40:50 +00:00
680e91c75c
Initally used a new sniff with autofix (T333745) Bug: T332865 Change-Id: I8b6fbfc300d62a10da770c8a1ca61756c7d7bf59
55 lines
1.1 KiB
PHP
55 lines
1.1 KiB
PHP
<?php
|
|
|
|
use MediaWiki\User\UserOptionsLookup;
|
|
|
|
/**
|
|
* @coversDefaultClass EchoContainmentSet
|
|
*/
|
|
class EchoContainmentSetTest extends MediaWikiIntegrationTestCase {
|
|
|
|
/**
|
|
* @covers ::addTitleIDsFromUserOption
|
|
* @dataProvider addTitlesFromUserOptionProvider
|
|
* @param string $prefData
|
|
* @param string $contains
|
|
* @param bool $expected
|
|
*/
|
|
public function testAddTitlesFromUserOption(
|
|
$prefData, string $contains, bool $expected
|
|
) {
|
|
$userOptionsLookupMock = $this->createMock( UserOptionsLookup::class );
|
|
$userOptionsLookupMock->method( 'getOption' )->willReturn( $prefData );
|
|
$this->setService( 'UserOptionsLookup', $userOptionsLookupMock );
|
|
$containmentSet = new EchoContainmentSet( $this->createMock( User::class ) );
|
|
$containmentSet->addTitleIDsFromUserOption( 'preference-name' );
|
|
$this->assertSame( $expected, $containmentSet->contains( $contains ) );
|
|
}
|
|
|
|
public static function addTitlesFromUserOptionProvider(): array {
|
|
return [
|
|
[
|
|
'foo',
|
|
'bar',
|
|
false
|
|
],
|
|
[
|
|
[ 'foo', 'bar' ],
|
|
'foo',
|
|
false
|
|
],
|
|
[
|
|
"foo\nbar",
|
|
'bar',
|
|
true
|
|
],
|
|
[
|
|
'{"foo":"bar"}',
|
|
'bar',
|
|
false
|
|
]
|
|
|
|
];
|
|
}
|
|
|
|
}
|