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( "*Perform high volume activity\n:High-volume (bot) access\n\n", $this->grantsLocalization->getGrantsWikiText( [ 'highvolume' ] ) ); } }