3 namespace Friendica\Test\src\Core\Console;
5 use Friendica\Database\DBA;
8 * @runTestsInSeparateProcesses
9 * @preserveGlobalState disabled
12 class ConfigConsoleTest extends ConsoleTest
14 public function tearDown()
16 DBA::delete('config', ['k' => 'test']);
21 private function assertGet($family, $key, $value) {
22 $config = $this->execute(['config', $family, $key]);
23 $this->assertEquals($family . "." . $key . " => " . $value . "\n", $config);
26 private function assertSet($family, $key, $value) {
27 $config = $this->execute(['config', $family, $key, $value]);
28 $this->assertEquals($family . "." . $key . " <= " . $value . "\n", $config);
31 function testSetGetKeyValue() {
32 $this->assertSet( 'config', 'test', 'now');
33 $this->assertGet('config', 'test', 'now');
34 $this->assertSet('config', 'test', '');
35 $this->assertGet('config', 'test', '');
36 DBA::delete('config', ['k' => 'test']);
37 $this->assertGet('config', 'test', null);
40 function testSetArrayValue() {
41 $testArray = [1, 2, 3];
42 DBA::insert('config', ['cat' => 'config', 'k' => 'test', 'v' => serialize($testArray)]);
44 $txt = $this->execute(['config', 'config', 'test', 'now']);
46 $this->assertEquals("[Error] config.test is an array and can't be set using this command.\n", $txt);
49 function testTooManyArguments() {
50 $txt = $this->execute(['config', 'config', 'test', 'it', 'now']);
51 $assertion = '[Warning] Too many arguments';
52 $firstline = substr($txt, 0, strlen($assertion));
54 $this->assertEquals($assertion, $firstline);
57 function testVerbose() {
58 $this->assertSet('test', 'it', 'now');
59 $executable = $this->getExecutablePath();
61 Executable: {$executable}
70 Executable: {$executable}
71 Class: Friendica\Core\Console\Config
82 $txt = $this->execute(['config', 'test', '-v']);
84 $this->assertEquals($assertion, $txt);