mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-28 07:33:04 +00:00
a0ca1d89c6
Changes to the use statements done automatically via script Addition of missing use statements done manually Change-Id: Iad87245bf8082193be72f7e482f29e9f1bad11fc
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\Options\UserOptionsLookup;
|
|
use MediaWiki\User\User;
|
|
use MediaWikiIntegrationTestCase;
|
|
|
|
/**
|
|
* @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
|
|
]
|
|
|
|
];
|
|
}
|
|
|
|
}
|