mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-13 16:39:32 +00:00
fba5bcec19
Change-Id: I90a0c9e7b1ac17edeed5f706a8f968f6d67df56f
59 lines
1.1 KiB
PHP
59 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @coversDefaultClass EchoContainmentSet
|
|
*/
|
|
class EchoContainmentSetTest extends \MediaWikiUnitTestCase {
|
|
|
|
/**
|
|
* @covers ::addTitleIDsFromUserOption
|
|
* @dataProvider addTitlesFromUserOptionProvider
|
|
* @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();
|
|
}
|
|
|
|
}
|