Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / maintenance / AddChangeTagTest.php
blob54e634b521e03c0e68ec0bb7d400c51b51bd5e5c
1 <?php
3 namespace MediaWiki\Tests\Maintenance;
5 use AddChangeTag;
7 /**
8 * @covers \AddChangeTag
9 * @group Database
10 * @author Dreamy Jazz
12 class AddChangeTagTest extends MaintenanceBaseTestCase {
13 public function getMaintenanceClass() {
14 return AddChangeTag::class;
17 public function testExecuteForEmptyTagOption() {
18 $this->expectCallToFatalError();
19 $expectedErrorMessage = wfMessage( 'tags-create-no-name' )->text();
20 $this->expectOutputRegex( "/$expectedErrorMessage/" );
21 $this->maintenance->setOption( 'tag', '' );
22 $this->maintenance->setOption( 'reason', 'test' );
23 $this->maintenance->execute();
26 public function testExecuteForSuccessfulCreation() {
27 $this->maintenance->setOption( 'tag', 'new-test-tag' );
28 $this->maintenance->setOption( 'reason', 'testing' );
29 $this->expectOutputRegex( '/new-test-tag was created/' );
30 $this->maintenance->execute();
31 // Validate that the tag actually exists in the DB.
32 $this->newSelectQueryBuilder()
33 ->select( 'COUNT(*)' )
34 ->from( 'change_tag_def' )
35 ->where( [ 'ctd_name' => 'new-test-tag' ] )
36 ->assertFieldValue( 1 );