Why: * Most of the maintenance scripts in core are untested, and testing some of the less complex scripts can be easily done. * This will help to improve the test coverage on core. What: * Add PageExistsTest which tests pageExists.php. Bug: T371167 Change-Id: I29b207208787e3443cd58b8889d49f39dae20420
35 lines
820 B
PHP
35 lines
820 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\Maintenance;
|
|
|
|
use PageExists;
|
|
|
|
/**
|
|
* @covers \PageExists
|
|
* @group Database
|
|
* @author Dreamy Jazz
|
|
*/
|
|
class PageExistsTest extends MaintenanceBaseTestCase {
|
|
|
|
protected function getMaintenanceClass() {
|
|
return PageExists::class;
|
|
}
|
|
|
|
public function testExecuteForNonExistingPage() {
|
|
$nonExistentTestPage = $this->getNonexistingTestPage();
|
|
$this->maintenance->setArg( 'title', $nonExistentTestPage );
|
|
$this->maintenance->execute();
|
|
$this->expectOutputString(
|
|
"$nonExistentTestPage doesn't exist.\n"
|
|
);
|
|
}
|
|
|
|
public function testExecuteForExistingPage() {
|
|
$existingTestPage = $this->getExistingTestPage();
|
|
$this->maintenance->setArg( 'title', $existingTestPage );
|
|
$this->maintenance->execute();
|
|
$this->expectOutputString(
|
|
"$existingTestPage exists.\n"
|
|
);
|
|
}
|
|
}
|