Bugfixing executable (Mocking the executable)
This commit is contained in:
parent
92d3d77e76
commit
d75cc0cb34
|
@ -224,7 +224,7 @@ CONF;
|
||||||
->at($this->root)
|
->at($this->root)
|
||||||
->setContent($config);
|
->setContent($config);
|
||||||
|
|
||||||
$console = new AutomaticInstallation();
|
$console = new AutomaticInstallation($this->consoleArgv);
|
||||||
$console->setOption('f', 'prepared.ini.php');
|
$console->setOption('f', 'prepared.ini.php');
|
||||||
|
|
||||||
$txt = $this->dumpExecute($console);
|
$txt = $this->dumpExecute($console);
|
||||||
|
@ -249,7 +249,7 @@ CONF;
|
||||||
$this->assertTrue(putenv('FRIENDICA_LANG=de'));
|
$this->assertTrue(putenv('FRIENDICA_LANG=de'));
|
||||||
$this->assertTrue(putenv('FRIENDICA_URL_PATH=/friendica'));
|
$this->assertTrue(putenv('FRIENDICA_URL_PATH=/friendica'));
|
||||||
|
|
||||||
$console = new AutomaticInstallation();
|
$console = new AutomaticInstallation($this->consoleArgv);
|
||||||
$console->setOption('savedb', true);
|
$console->setOption('savedb', true);
|
||||||
|
|
||||||
$txt = $this->dumpExecute($console);
|
$txt = $this->dumpExecute($console);
|
||||||
|
@ -278,7 +278,7 @@ CONF;
|
||||||
$this->assertTrue(putenv('FRIENDICA_LANG=de'));
|
$this->assertTrue(putenv('FRIENDICA_LANG=de'));
|
||||||
$this->assertTrue(putenv('FRIENDICA_URL_PATH=/friendica'));
|
$this->assertTrue(putenv('FRIENDICA_URL_PATH=/friendica'));
|
||||||
|
|
||||||
$console = new AutomaticInstallation();
|
$console = new AutomaticInstallation($this->consoleArgv);
|
||||||
|
|
||||||
$txt = $this->dumpExecute($console);
|
$txt = $this->dumpExecute($console);
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ CONF;
|
||||||
$this->mockExistsTable('user', false, 1);
|
$this->mockExistsTable('user', false, 1);
|
||||||
$this->mockUpdate([false, true, true], null, 1);
|
$this->mockUpdate([false, true, true], null, 1);
|
||||||
|
|
||||||
$console = new AutomaticInstallation();
|
$console = new AutomaticInstallation($this->consoleArgv);
|
||||||
|
|
||||||
$console->setOption('dbhost', $this->db_host);
|
$console->setOption('dbhost', $this->db_host);
|
||||||
$console->setOption('dbuser', $this->db_user);
|
$console->setOption('dbuser', $this->db_user);
|
||||||
|
@ -338,7 +338,7 @@ CONF;
|
||||||
{
|
{
|
||||||
$this->mockConnect(false, 1);
|
$this->mockConnect(false, 1);
|
||||||
|
|
||||||
$console = new AutomaticInstallation();
|
$console = new AutomaticInstallation($this->consoleArgv);
|
||||||
|
|
||||||
$txt = $this->dumpExecute($console);
|
$txt = $this->dumpExecute($console);
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ Examples
|
||||||
|
|
||||||
HELP;
|
HELP;
|
||||||
|
|
||||||
$console = new AutomaticInstallation();
|
$console = new AutomaticInstallation($this->consoleArgv);
|
||||||
$console->setOption('help', true);
|
$console->setOption('help', true);
|
||||||
|
|
||||||
$txt = $this->dumpExecute($console);
|
$txt = $this->dumpExecute($console);
|
||||||
|
|
|
@ -33,7 +33,7 @@ class ConfigConsoleTest extends ConsoleTest
|
||||||
|
|
||||||
function testSetGetKeyValue() {
|
function testSetGetKeyValue() {
|
||||||
$this->mockConfigSet('config', 'test', 'now', 1);
|
$this->mockConfigSet('config', 'test', 'now', 1);
|
||||||
$console = new Config();
|
$console = new Config($this->consoleArgv);
|
||||||
$console->setArgument(0, 'config');
|
$console->setArgument(0, 'config');
|
||||||
$console->setArgument(1, 'test');
|
$console->setArgument(1, 'test');
|
||||||
$console->setArgument(2, 'now');
|
$console->setArgument(2, 'now');
|
||||||
|
@ -41,14 +41,14 @@ class ConfigConsoleTest extends ConsoleTest
|
||||||
$this->assertEquals("config.test <= now\n", $txt);
|
$this->assertEquals("config.test <= now\n", $txt);
|
||||||
|
|
||||||
$this->mockConfigGet('config', 'test', 'now', 1);
|
$this->mockConfigGet('config', 'test', 'now', 1);
|
||||||
$console = new Config();
|
$console = new Config($this->consoleArgv);
|
||||||
$console->setArgument(0, 'config');
|
$console->setArgument(0, 'config');
|
||||||
$console->setArgument(1, 'test');
|
$console->setArgument(1, 'test');
|
||||||
$txt = $this->dumpExecute($console);
|
$txt = $this->dumpExecute($console);
|
||||||
$this->assertEquals("config.test => now\n", $txt);
|
$this->assertEquals("config.test => now\n", $txt);
|
||||||
|
|
||||||
$this->mockConfigGet('config', 'test', null, 1);
|
$this->mockConfigGet('config', 'test', null, 1);
|
||||||
$console = new Config();
|
$console = new Config($this->consoleArgv);
|
||||||
$console->setArgument(0, 'config');
|
$console->setArgument(0, 'config');
|
||||||
$console->setArgument(1, 'test');
|
$console->setArgument(1, 'test');
|
||||||
$txt = $this->dumpExecute($console);
|
$txt = $this->dumpExecute($console);
|
||||||
|
@ -59,7 +59,7 @@ class ConfigConsoleTest extends ConsoleTest
|
||||||
$testArray = [1, 2, 3];
|
$testArray = [1, 2, 3];
|
||||||
$this->mockConfigGet('config', 'test', $testArray, 1);
|
$this->mockConfigGet('config', 'test', $testArray, 1);
|
||||||
|
|
||||||
$console = new Config();
|
$console = new Config($this->consoleArgv);
|
||||||
$console->setArgument(0, 'config');
|
$console->setArgument(0, 'config');
|
||||||
$console->setArgument(1, 'test');
|
$console->setArgument(1, 'test');
|
||||||
$console->setArgument(2, 'now');
|
$console->setArgument(2, 'now');
|
||||||
|
@ -69,7 +69,7 @@ class ConfigConsoleTest extends ConsoleTest
|
||||||
}
|
}
|
||||||
|
|
||||||
function testTooManyArguments() {
|
function testTooManyArguments() {
|
||||||
$console = new Config();
|
$console = new Config($this->consoleArgv);
|
||||||
$console->setArgument(0, 'config');
|
$console->setArgument(0, 'config');
|
||||||
$console->setArgument(1, 'test');
|
$console->setArgument(1, 'test');
|
||||||
$console->setArgument(2, 'it');
|
$console->setArgument(2, 'it');
|
||||||
|
@ -82,12 +82,13 @@ class ConfigConsoleTest extends ConsoleTest
|
||||||
|
|
||||||
function testVerbose() {
|
function testVerbose() {
|
||||||
$this->mockConfigGet('test', 'it', 'now', 1);
|
$this->mockConfigGet('test', 'it', 'now', 1);
|
||||||
$console = new Config();
|
$console = new Config($this->consoleArgv);
|
||||||
$console->setArgument(0, 'test');
|
$console->setArgument(0, 'test');
|
||||||
$console->setArgument(1, 'it');
|
$console->setArgument(1, 'it');
|
||||||
$console->setOption('v', 1);
|
$console->setOption('v', 1);
|
||||||
|
$executable = $this->consoleArgv[0];
|
||||||
$assertion = <<<CONF
|
$assertion = <<<CONF
|
||||||
Executable: -
|
Executable: {$executable}
|
||||||
Class: Friendica\Core\Console\Config
|
Class: Friendica\Core\Console\Config
|
||||||
Arguments: array (
|
Arguments: array (
|
||||||
0 => 'test',
|
0 => 'test',
|
||||||
|
@ -112,4 +113,45 @@ CONF;
|
||||||
$txt = $this->dumpExecute($console);
|
$txt = $this->dumpExecute($console);
|
||||||
$this->assertSame("Unable to set test.it\n", $txt);
|
$this->assertSame("Unable to set test.it\n", $txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetHelp()
|
||||||
|
{
|
||||||
|
// Usable to purposely fail if new commands are added without taking tests into account
|
||||||
|
$theHelp = <<<HELP
|
||||||
|
console config - Manage site configuration
|
||||||
|
Synopsis
|
||||||
|
bin/console config [-h|--help|-?] [-v]
|
||||||
|
bin/console config <category> [-h|--help|-?] [-v]
|
||||||
|
bin/console config <category> <key> [-h|--help|-?] [-v]
|
||||||
|
bin/console config <category> <key> <value> [-h|--help|-?] [-v]
|
||||||
|
|
||||||
|
Description
|
||||||
|
bin/console config
|
||||||
|
Lists all config values
|
||||||
|
|
||||||
|
bin/console config <category>
|
||||||
|
Lists all config values in the provided category
|
||||||
|
|
||||||
|
bin/console config <category> <key>
|
||||||
|
Shows the value of the provided key in the category
|
||||||
|
|
||||||
|
bin/console config <category> <key> <value>
|
||||||
|
Sets the value of the provided key in the category
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
Setting config entries which are manually set in config/local.ini.php may result in
|
||||||
|
conflict between database settings and the manual startup settings.
|
||||||
|
|
||||||
|
Options
|
||||||
|
-h|--help|-? Show help information
|
||||||
|
-v Show more debug information.
|
||||||
|
|
||||||
|
HELP;
|
||||||
|
$console = new Config($this->consoleArgv);
|
||||||
|
$console->setOption('help', true);
|
||||||
|
|
||||||
|
$txt = $this->dumpExecute($console);
|
||||||
|
|
||||||
|
$this->assertEquals($txt, $theHelp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,10 @@ abstract class ConsoleTest extends TestCase
|
||||||
use VFSTrait;
|
use VFSTrait;
|
||||||
use AppMockTrait;
|
use AppMockTrait;
|
||||||
|
|
||||||
protected $stdout;
|
/**
|
||||||
|
* @var array The default argv for a Console Instance
|
||||||
|
*/
|
||||||
|
protected $consoleArgv = [ 'consoleTest.php' ];
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user