/**
  * This method creates config if it doesn't exist so test won't fail
  *
  */
 function createConfigIfNotExists()
 {
     if (!file_exists(MAX_PATH . '/var/' . OX_getHostName() . '.conf.php')) {
         $oConfig = new OA_Upgrade_Config();
         $oConfig->writeConfig(true);
     }
 }
 /**
  * This function checks for any new items in the config dist file
  */
 function test_checkForConfigAdditions()
 {
     $oUpConfig = new OA_Upgrade_Config();
     // First check that the working config file agrees with the dist config file
     $this->assertFalse($oUpConfig->checkForConfigAdditions($new), 'New config items have NOT been added to working test.conf.php');
     // Assert no new items detected when $new === $old
     $new = $oUpConfig->aConfig;
     $this->assertFalse($oUpConfig->checkForConfigAdditions($new), 'New dist.conf.php items mistakenly detected');
     // Add a new item to an existing sub-array
     $new = $oUpConfig->aConfig;
     $new['database']['key'] = 'value';
     $this->assertTrue($oUpConfig->checkForConfigAdditions($new), 'New dist.conf.php items (added to existing section) not detected');
     // Add a completely new empty sub-array
     $new = $oUpConfig->aConfig;
     $new['newSubArray'] = array();
     $this->assertTrue($oUpConfig->checkForConfigAdditions($new), 'New dist.conf.php items (empty section) not detected');
     // Add a new sub-array with a new item
     $new = $oUpConfig->aConfig;
     $new['newSubArray'] = array('key' => 'value');
     $this->assertTrue($oUpConfig->checkForConfigAdditions($new), 'New dist.conf.php items (new section with value) not detected');
     // Add a new item not in a sub-array (so top level)
     $new = $oUpConfig->aConfig;
     $new['key'] = 'value';
     $this->assertTrue($oUpConfig->checkForConfigAdditions($new), 'New (top level) dist.conf.php items not detected');
 }
 /**
  * A private method that writes out the new OpenX settings configuration
  * file after migrating over the admin account's preferences that have
  * now been changed into settings.
  *
  * @access private
  * @return boolean True if the config file is successfully written,
  *                 otherwise, false.
  */
 function _writeSettings()
 {
     $oConfiguration = new OA_Upgrade_Config();
     foreach ($this->aConfMap as $section => $aPairs) {
         foreach ($aPairs as $key => $value) {
             $value = $this->aConfNew[$section][$key];
             $oConfiguration->setValue($section, $key, $value);
         }
     }
     return $oConfiguration->writeConfig();
 }