<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Friendica\App;
use Friendica\App\Mode;
use Friendica\Console\Config;
-use Friendica\Core\Config\IConfig;
+use Friendica\Core\Config\Capability\IManageConfigValues;
use Mockery;
use Mockery\LegacyMockInterface;
use Mockery\MockInterface;
* @var App\Mode|MockInterface $appMode
*/
private $appMode;
- /** @var IConfig|LegacyMockInterface|MockInterface */
+ /** @var IManageConfigValues|LegacyMockInterface|MockInterface */
private $configMock;
- protected function setUp()
+ protected function setUp() : void
{
parent::setUp();
$this->appMode->shouldReceive('has')
->andReturn(true);
- $this->configMock = Mockery::mock(IConfig::class);
+ $this->configMock = Mockery::mock(IManageConfigValues::class);
}
public function testSetGetKeyValue()
$this->configMock
->shouldReceive('get')
->with('config', 'test')
- ->andReturn('now')
+ ->andReturn('old')
->twice();
+ $this->configMock
+ ->shouldReceive('get')
+ ->with('config', 'test')
+ ->andReturn('now')
+ ->once();
$console = new Config($this->appMode, $this->configMock, $this->consoleArgv);
$console->setArgument(0, 'config');
$console->setArgument(0, 'config');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
- self::assertEquals("config.test => \n", $txt);
+ self::assertEquals("config.test => NULL\n", $txt);
}
public function testSetArrayValue()
self::assertEquals("[Error] config.test is an array and can't be set using this command.\n", $txt);
}
+ public function testSetExistingValue()
+ {
+ $this->configMock
+ ->shouldReceive('get')
+ ->with('config', 'test')
+ ->andReturn('now')
+ ->twice();
+
+ $console = new Config($this->appMode, $this->configMock, $this->consoleArgv);
+ $console->setArgument(0, 'config');
+ $console->setArgument(1, 'test');
+ $console->setArgument(2, 'now');
+ $txt = $this->dumpExecute($console);
+
+ self::assertEquals("[Error] config.test already set to now.\n", $txt);
+ }
+
public function testTooManyArguments()
{
$console = new Config($this->appMode, $this->configMock, $this->consoleArgv);
->shouldReceive('get')
->with('test', 'it')
->andReturn(null)
- ->once();
+ ->twice();
$console = new Config($this->appMode, $this->configMock, [$this->consoleArgv]);
$console->setArgument(0, 'test');
$console->setArgument(1, 'it');