2020-04-20 19:40:07 +00:00
|
|
|
<?php
|
|
|
|
|
2021-12-01 18:29:00 +00:00
|
|
|
use MediaWiki\User\UserOptionsLookup;
|
|
|
|
|
2020-04-20 19:40:07 +00:00
|
|
|
/**
|
|
|
|
* @coversDefaultClass EchoContainmentSet
|
|
|
|
*/
|
2021-12-01 18:29:00 +00:00
|
|
|
class EchoContainmentSetTest extends MediaWikiIntegrationTestCase {
|
2020-04-20 19:40:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::addTitleIDsFromUserOption
|
|
|
|
* @dataProvider addTitlesFromUserOptionProvider
|
|
|
|
* @param string $prefData
|
|
|
|
* @param string $contains
|
|
|
|
* @param bool $expected
|
|
|
|
*/
|
|
|
|
public function testAddTitlesFromUserOption(
|
|
|
|
$prefData, string $contains, bool $expected
|
|
|
|
) {
|
2021-12-01 18:29:00 +00:00
|
|
|
$userOptionsLookupMock = $this->createMock( UserOptionsLookup::class );
|
|
|
|
$userOptionsLookupMock->method( 'getOption' )->willReturn( $prefData );
|
|
|
|
$this->setService( 'UserOptionsLookup', $userOptionsLookupMock );
|
2022-09-29 13:41:35 +00:00
|
|
|
$containmentSet = new EchoContainmentSet( $this->createMock( User::class ) );
|
2020-04-20 19:40:07 +00:00
|
|
|
$containmentSet->addTitleIDsFromUserOption( 'preference-name' );
|
|
|
|
$this->assertSame( $expected, $containmentSet->contains( $contains ) );
|
|
|
|
}
|
|
|
|
|
2021-07-23 21:23:16 +00:00
|
|
|
public function addTitlesFromUserOptionProvider(): array {
|
2020-04-20 19:40:07 +00:00
|
|
|
return [
|
|
|
|
[
|
|
|
|
'foo',
|
|
|
|
'bar',
|
|
|
|
false
|
|
|
|
],
|
|
|
|
[
|
|
|
|
[ 'foo', 'bar' ],
|
|
|
|
'foo',
|
|
|
|
false
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"foo\nbar",
|
|
|
|
'bar',
|
|
|
|
true
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'{"foo":"bar"}',
|
|
|
|
'bar',
|
|
|
|
false
|
|
|
|
]
|
|
|
|
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|