Merge "Start on tests for install.php"

This commit is contained in:
jenkins-bot 2024-08-30 20:17:55 +00:00 committed by Gerrit Code Review
commit 750aa11700
2 changed files with 34 additions and 2 deletions

View file

@ -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

View 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();
}
}