mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 01:30:15 +00:00
e576cbdca0
Change-Id: If1405788a4adb550e8a7e8c58b0c2c55cf10ea67
60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Notifications\Test\Integration;
|
|
|
|
use MediaWiki\Extension\Notifications\ContainmentSet;
|
|
use MediaWiki\User\UserOptionsLookup;
|
|
use MediaWikiIntegrationTestCase;
|
|
use User;
|
|
|
|
/**
|
|
* @coversDefaultClass \MediaWiki\Extension\Notifications\ContainmentSet
|
|
*/
|
|
class ContainmentSetTest 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 ContainmentSet( $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
|
|
]
|
|
|
|
];
|
|
}
|
|
|
|
}
|