mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-12 07:55:53 +00:00
a3c55f6272
Replace User::getOption() with UserOptionsLookup::getOption() since this method will be hard-deprecated. Bug: T296083 Change-Id: I0ecdc63b0344bc4c24196cc5edb3d02b6a7ed615
62 lines
1.3 KiB
PHP
62 lines
1.3 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
|
|
) {
|
|
$user = $this->getDefaultUserMock();
|
|
$userOptionsLookupMock = $this->createMock( UserOptionsLookup::class );
|
|
$userOptionsLookupMock->method( 'getOption' )->willReturn( $prefData );
|
|
$this->setService( 'UserOptionsLookup', $userOptionsLookupMock );
|
|
$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();
|
|
}
|
|
|
|
}
|