mediawiki-extensions-Echo/tests/phpunit/integration/ContainmentSetTest.php
Umherirrender a0ca1d89c6 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statements done manually

Change-Id: Iad87245bf8082193be72f7e482f29e9f1bad11fc
2023-12-11 16:39:00 +01:00

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