Merge "Start on tests for install.php"
This commit is contained in:
commit
750aa11700
2 changed files with 34 additions and 2 deletions
|
|
@ -134,8 +134,7 @@ class CommandLineInstaller extends Maintenance {
|
|||
|
||||
// Manually check for required arguments, as 0 arguments allows interactive mode to be used
|
||||
if ( $this->getArg( 0 ) && !$this->getArg( 1 ) ) {
|
||||
$this->error( 'Argument <' . $this->getArgName( 1 ) . '> is required!' );
|
||||
return false;
|
||||
$this->fatalError( 'Argument <' . $this->getArgName( 1 ) . '> is required!' );
|
||||
}
|
||||
|
||||
// No arguments, means interactive mode
|
||||
|
|
|
|||
33
tests/phpunit/maintenance/CommandLineInstallerTest.php
Normal file
33
tests/phpunit/maintenance/CommandLineInstallerTest.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Tests\Maintenance;
|
||||
|
||||
use CommandLineInstaller;
|
||||
|
||||
/**
|
||||
* @covers \CommandLineInstaller
|
||||
* @author Dreamy Jazz
|
||||
*/
|
||||
class CommandLineInstallerTest extends MaintenanceBaseTestCase {
|
||||
public function getMaintenanceClass() {
|
||||
return CommandLineInstaller::class;
|
||||
}
|
||||
|
||||
public function testExecuteWhenHelpSpecified() {
|
||||
$this->maintenance->setOption( 'help', 1 );
|
||||
// ::maybeShowHelp uses ->mName which is null unless we call this.
|
||||
$this->maintenance->setName( 'install.php' );
|
||||
$this->expectCallToFatalError();
|
||||
$this->expectOutputString( $this->maintenance->getParameters()->getHelp() . "\n" );
|
||||
$this->maintenance->execute();
|
||||
}
|
||||
|
||||
public function testExecuteWhenFirstArgumentProvidedButNotSecond() {
|
||||
$this->maintenance->setArg( 'name', 'mediawiki' );
|
||||
// ::maybeShowHelp uses ->mName which is null unless we call this.
|
||||
$this->maintenance->setName( 'install.php' );
|
||||
$this->expectCallToFatalError();
|
||||
$this->expectOutputRegex( '/Argument \<admin\> is required/' );
|
||||
$this->maintenance->execute();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue