| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Tests\Maintenance; |
| 4 |
|
| 5 |
use AddChangeTag; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
class AddChangeTagTest extends MaintenanceBaseTestCase { |
| 13 |
public function getMaintenanceClass() { |
| 14 |
return AddChangeTag::class; |
| 15 |
} |
| 16 |
|
| 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(); |
| 24 |
} |
| 25 |
|
| 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 |
|
| 32 |
$this->newSelectQueryBuilder() |
| 33 |
->select( 'COUNT(*)' ) |
| 34 |
->from( 'change_tag_def' ) |
| 35 |
->where( [ 'ctd_name' => 'new-test-tag' ] ) |
| 36 |
->assertFieldValue( 1 ); |
| 37 |
} |
| 38 |
} |