mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-25 00:05:29 +00:00
4bf8a6736a
composer: * mediawiki/mediawiki-codesniffer: 24.0.0 → 26.0.0 npm: * set-value: 2.0.0 → 2.0.1 * https://npmjs.com/advisories/1012 * CVE-2019-10747 * union-value: 1.0.0 → 1.0.1 * https://npmjs.com/advisories/1012 * CVE-2019-10747 * mixin-deep: 1.3.1 → 1.3.2 * https://npmjs.com/advisories/1013 * CVE-2019-10746 Change-Id: I6d3efdf65c207b98447565e2df6f0698aaa8ea6b
70 lines
1.8 KiB
PHP
70 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group Echo
|
|
*/
|
|
class EchoSummaryParserTest extends MediaWikiTestCase {
|
|
private $existingUsers = [
|
|
'Werdna',
|
|
'Jorm',
|
|
'Jim Carter',
|
|
];
|
|
|
|
/**
|
|
* @covers EchoSummaryParser::parse
|
|
* @dataProvider provideParse
|
|
*
|
|
* @param string $summary
|
|
* @param string[] $expectedUsers
|
|
*/
|
|
public function testParse( $summary, array $expectedUsers ) {
|
|
$parser = new EchoSummaryParser( function ( User $user ) {
|
|
if ( in_array( $user->getName(), $this->existingUsers ) ) {
|
|
return crc32( $user->getName() );
|
|
}
|
|
return 0;
|
|
} );
|
|
|
|
$users = $parser->parse( $summary );
|
|
foreach ( $users as $name => $user ) {
|
|
$this->assertType( User::class, $user );
|
|
$this->assertEquals( $name, $user->getName() );
|
|
}
|
|
|
|
$users = array_keys( $users );
|
|
|
|
$this->assertArrayEquals( $expectedUsers, $users );
|
|
}
|
|
|
|
public function provideParse() {
|
|
return [
|
|
[ '', [] ],
|
|
[ " \t\r\n ", [] ],
|
|
[ 'foo bar', [] ],
|
|
[ 'Werdna', [] ],
|
|
[ 'User:Werdna', [] ],
|
|
[ '[User:Werdna]', [] ],
|
|
[ '[[]]', [] ],
|
|
[ '[[:]]', [] ],
|
|
[ '[[|]]', [] ],
|
|
[ '[[:|]]', [] ],
|
|
[ '[[:|test]]', [] ],
|
|
[ '[[User:Nonexistent]]', [] ],
|
|
[ '/* [[User:Werdna */', [] ],
|
|
[ '[[User talk:Werdna]]', [] ],
|
|
[ '[[User:Werdna]]', [ 'Werdna' ] ],
|
|
[ 'this is [[ [[User:Werdna]] ]]', [ 'Werdna' ] ],
|
|
[ '[[User:Werdna|]]', [ 'Werdna' ] ],
|
|
[ '[[User:Werdna| ]]', [ 'Werdna' ] ],
|
|
[ '[[User:Werdna|Wer | d[n]a]]', [ 'Werdna' ] ],
|
|
[ '[[User:Werdna]][[User:Werdna]][[User:Werdna]]', [ 'Werdna' ] ],
|
|
[ '/**/[[User:Werdna]][[user:jorm]]', [ 'Werdna', 'Jorm' ] ],
|
|
[ '/* [[User:Werdna]] */ [[ user : jim_ Carter_]]', [ 'Jim Carter' ] ],
|
|
[ '[[User:/* Jorm */]][[User:/* remove me */Werdna]]', [] ],
|
|
[ '[[:User:Werdna]]', [] ],
|
|
[ '[[:User:Werdna|]]', [] ],
|
|
[ '[[:User:Werdna|foo]]', [] ],
|
|
];
|
|
}
|
|
}
|