mediawiki-extensions-Echo/tests/phpunit/integration/EchoContainmentSetTest.php
Thiemo Kreuz db79d76d83 Use PHPUnit's shortcuts where it makes sense
Notably: any() is the default anyway. It doesn't really make the
tests more specific or better readable when we repeat it all the
time.

Change-Id: I56d201bfce454587b00015b7208f313dd8ed9624
2022-10-26 11:53:57 +02:00

55 lines
1.1 KiB
PHP

<?php
use MediaWiki\User\UserOptionsLookup;
/**
* @coversDefaultClass EchoContainmentSet
*/
class EchoContainmentSetTest 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 EchoContainmentSet( $this->createMock( User::class ) );
$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
]
];
}
}