3 namespace MediaWiki\Tests\Maintenance
;
8 * @covers \AddChangeTag
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 );