mediawiki-extensions-Echo/tests/phpunit/integration/ContainmentSetTest.php
Reedy e576cbdca0 Namespace some more classes
Change-Id: If1405788a4adb550e8a7e8c58b0c2c55cf10ea67
2023-08-18 21:24:59 +01:00

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
]
];
}
}