mediawiki-extensions-Echo/tests/phpunit/unit/EchoContainmentSetTest.php
libraryupgrader 17a644263a build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs are failing and were disabled:
  * PSR12.Functions.ReturnTypeDeclaration.SpaceBeforeReturnType

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)
* postcss: 7.0.35 → 7.0.36
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)
* trim-newlines: 3.0.0 → 3.0.1
  * https://npmjs.com/advisories/1753 (CVE-2021-33623)

Change-Id: Id866782d39ac02a329bd79539f2d52392fffd296
2021-07-24 01:48:06 +00:00

59 lines
1.1 KiB
PHP

<?php
/**
* @coversDefaultClass EchoContainmentSet
*/
class EchoContainmentSetTest extends \MediaWikiUnitTestCase {
/**
* @covers ::addTitleIDsFromUserOption
* @dataProvider addTitlesFromUserOptionProvider
* @param string $prefData
* @param string $contains
* @param bool $expected
*/
public function testAddTitlesFromUserOption(
$prefData, string $contains, bool $expected
) {
$user = $this->getDefaultUserMock();
$user->method( 'getOption' )
->willReturn( $prefData );
$containmentSet = new EchoContainmentSet( $user );
$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
]
];
}
private function getDefaultUserMock() {
return $this->getMockBuilder( User::class )
->disableOriginalConstructor()
->getMock();
}
}