Esempio n. 1
0
 public function testSetValue()
 {
     $this->config->setDebugMode(false);
     $this->config->setValue('foo', 'moo');
     $this->assertAttributeEquals(array('foo' => 'moo'), 'cache', $this->config);
     $content = file_get_contents(self::CONFIG_FILE);
     $expected = "<?php\n\$CONFIG = array (\n  'foo' => 'moo',\n);\n";
     $this->assertEquals($expected, $content);
     $this->config->setValue('bar', 'red');
     $this->assertAttributeEquals(array('foo' => 'moo', 'bar' => 'red'), 'cache', $this->config);
     $content = file_get_contents(self::CONFIG_FILE);
     $expected = "<?php\n\$CONFIG = array (\n  'foo' => 'moo',\n  'bar' => 'red',\n);\n";
     $this->assertEquals($expected, $content);
 }
Esempio n. 2
0
 protected function saveDBInfo(InputInterface $input)
 {
     $type = $input->getArgument('type');
     $username = $input->getArgument('username');
     $dbhost = $input->getArgument('hostname');
     $dbname = $input->getArgument('database');
     $password = $input->getOption('password');
     if ($input->getOption('port')) {
         $dbhost .= ':' . $input->getOption('port');
     }
     $this->config->setValue('dbtype', $type);
     $this->config->setValue('dbname', $dbname);
     $this->config->setValue('dbhost', $dbhost);
     $this->config->setValue('dbuser', $username);
     $this->config->setValue('dbpassword', $password);
 }
Esempio n. 3
0
 public function testConfigMerge()
 {
     // Create additional config
     $additionalConfig = '<?php $CONFIG=array("php53"=>"totallyOutdated");';
     $additionalConfigPath = $this->randomTmpDir . 'additionalConfig.testconfig.php';
     file_put_contents($additionalConfigPath, $additionalConfig);
     // Reinstantiate the config to force a read-in of the additional configs
     $this->config = new \OC\Config($this->randomTmpDir, 'testconfig.php');
     // Ensure that the config value can be read and the config has not been modified
     $this->assertSame('totallyOutdated', $this->config->getValue('php53', 'bogusValue'));
     $this->assertEquals(self::TESTCONTENT, file_get_contents($this->configFile));
     // Write a new value to the config
     $this->config->setValue('CoolWebsites', array('demo.owncloud.org', 'owncloud.org', 'owncloud.com'));
     $expected = "<?php\n\$CONFIG = array (\n  'foo' => 'bar',\n  'beers' => \n  array (\n    0 => 'Appenzeller',\n  " . "  1 => 'Guinness',\n    2 => 'Kölsch',\n  ),\n  'alcohol_free' => false,\n  'php53' => 'totallyOutdated',\n  'CoolWebsites' => \n  array (\n  " . "  0 => 'demo.owncloud.org',\n    1 => 'owncloud.org',\n    2 => 'owncloud.com',\n  ),\n);\n";
     $this->assertEquals($expected, file_get_contents($this->configFile));
     // Cleanup
     unlink($additionalConfigPath);
 }
Esempio n. 4
0
 /**
  * @brief Sets a value
  * @param string $key key
  * @param string $value value
  *
  * This function sets the value and writes the config.php.
  *
  */
 public static function setValue($key, $value)
 {
     self::$object->setValue($key, $value);
 }
Esempio n. 5
0
 /**
  * Sets a new system wide value
  *
  * @param string $key the key of the value, under which will be saved
  * @param mixed $value the value that should be stored
  */
 public function setValue($key, $value)
 {
     $this->config->setValue($key, $value);
 }