throw new RuntimeException("$cat.$key is an array and can't be set using this command.");
}
+ if ($this->config->get($cat, $key) == $value) {
+ throw new RuntimeException("$cat.$key already set to $value.");
+ }
+
$result = $this->config->set($cat, $key, $value);
if ($result) {
$this->out("{$cat}.{$key} <= " .
$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');
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');