Mostly used find-and-replace: Find: /\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?)[\s\*]+/\s*(private|protected|public) (\$[a-z]\w+;\n)((?=\s*/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?))\n|) Replace with: \3 \1 \4 More could be done, but to keep this patch reasonably sized, I only changed the most obvious and unambiguously correct cases. In some cases, I also removed redundant doc comments on the constructor, and re-ordered the properties to match the constructor. Change-Id: I3f8427ae4f5d55177ae18986ef15d84d0e7bf6f4
95 lines
2.6 KiB
PHP
95 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\Integration\Permissions;
|
|
|
|
use HtmlArmor;
|
|
use MediaWiki\Html\Html;
|
|
use MediaWiki\Message\Message;
|
|
use MediaWiki\Permissions\GrantsLocalization;
|
|
use MediaWiki\SpecialPage\SpecialPage;
|
|
use MediaWikiIntegrationTestCase;
|
|
|
|
/**
|
|
* @author Zabe
|
|
*
|
|
* @covers \MediaWiki\Permissions\GrantsLocalization
|
|
*/
|
|
class GrantsLocalizationTest extends MediaWikiIntegrationTestCase {
|
|
private GrantsLocalization $grantsLocalization;
|
|
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
|
|
$this->grantsLocalization = $this->getServiceContainer()->getGrantsLocalization();
|
|
}
|
|
|
|
/**
|
|
* @dataProvider grantDescriptions
|
|
*/
|
|
public function testGetGrantDescription( string $grant ) {
|
|
$message = new Message( 'grant-' . $grant );
|
|
$this->assertSame(
|
|
$message->text(),
|
|
$this->grantsLocalization->getGrantDescription( $grant )
|
|
);
|
|
$this->assertSame(
|
|
$message->inLanguage( 'de' )->text(),
|
|
$this->grantsLocalization->getGrantDescription( $grant, 'de' )
|
|
);
|
|
}
|
|
|
|
public function grantDescriptions() {
|
|
yield [ 'blockusers' ];
|
|
yield [ 'createeditmovepage' ];
|
|
yield [ 'delete' ];
|
|
}
|
|
|
|
public function testGetNonExistingGrantDescription() {
|
|
$message = ( new Message( 'grant-generic' ) )->params( 'foo' );
|
|
$this->assertSame(
|
|
$message->text(),
|
|
$this->grantsLocalization->getGrantDescription( 'foo' )
|
|
);
|
|
$this->assertSame(
|
|
$message->inLanguage( 'zh' )->text(),
|
|
$this->grantsLocalization->getGrantDescription( 'foo', 'zh' )
|
|
);
|
|
}
|
|
|
|
public function testGetGrantDescriptions() {
|
|
$this->assertSame(
|
|
[
|
|
'blockusers' => ( new Message( 'grant-blockusers' ) )->inLanguage( 'de' )->text(),
|
|
'delete' => ( new Message( 'grant-delete' ) )->inLanguage( 'de' )->text(),
|
|
],
|
|
$this->grantsLocalization->getGrantDescriptions(
|
|
[
|
|
'blockusers',
|
|
'delete',
|
|
],
|
|
'de'
|
|
)
|
|
);
|
|
}
|
|
|
|
public function testGetGrantsLink() {
|
|
$this->assertSame(
|
|
$this->getServiceContainer()->getLinkRenderer()->makeKnownLink(
|
|
SpecialPage::getTitleFor( 'Listgrants', false, 'delete' ),
|
|
new HtmlArmor(
|
|
( new Message( 'grant-delete' ) )->escaped() . ' ' .
|
|
Html::element( 'span', [ 'class' => 'mw-grant mw-grantriskgroup-vandalism' ],
|
|
( new Message( 'grantriskgroup-vandalism' ) )->text() )
|
|
)
|
|
),
|
|
$this->grantsLocalization->getGrantsLink( 'delete' )
|
|
);
|
|
}
|
|
|
|
public function testGetGrantsWikiText() {
|
|
$this->assertSame(
|
|
"*<span class=\"mw-grantgroup\">Perform high volume activity</span>\n:High-volume (bot) access <span class=\"mw-grant mw-grantriskgroup-low\"></span>\n\n",
|
|
$this->grantsLocalization->getGrantsWikiText( [ 'highvolume' ] )
|
|
);
|
|
}
|
|
}
|