Exemplo n.º 1
0
 /**
  * @covers Helper_Modules::_getModulesAnalize
  */
 public function testGetModulesAnalizeTwo()
 {
     modConfig::setParameter("start", true);
     oxTestModules::addFunction('moduleManager', 'getModuleContentClass', '{ return true; }');
     oxTestModules::addFunction('moduleManagerAnalize', 'setAnalize', '{ return true; }');
     $oTestObj = $this->getProxyClass('Helper_Modules');
     $this->assertNull($oTestObj->UNITgetModulesAnalize());
 }
Exemplo n.º 2
0
 /**
  * Returns database dump data
  *
  * @return array
  */
 public function getDumpChecksum()
 {
     if (is_null($this->_aDBDump)) {
         modConfig::getInstance()->cleanup();
         modConfig::$unitMOD = null;
         $aDBDump = file_get_contents($this->getDumpFolderPath() . 'dbdata');
         $this->_aDBDump = unserialize($aDBDump);
     }
     return $this->_aDBDump;
 }
 /**
  * Testing the creating of a Barzahlen_Api object.
  */
 public function testGetBarzahlenApi()
 {
     modConfig::setParameter("oxid", "a6f9bc61ce7aec5dabb7600636f5ce1d");
     $oView = $this->getProxyClass('bz_barzahlen_payment_gateway');
     $oApi = $oView->_getBarzahlenApi(0);
     $this->assertAttributeEquals(SHOPID, '_shopId', $oApi);
     $this->assertAttributeEquals(PAYMENTKEY, '_paymentKey', $oApi);
     $this->assertAttributeEquals('de', '_language', $oApi);
     $this->assertAttributeEquals(true, '_sandbox', $oApi);
     $this->assertAttributeEquals(0, '_madeAttempts', $oApi);
 }
Exemplo n.º 4
0
 /**
  * Returns array of available currencies
  *
  * @param integer $iCurrency Active currency number (default null)
  *
  * @return array
  */
 public function getCurrencyArray($iCurrency = null)
 {
     $aConfCurrencies = $this->getConfigParam('aCurrencies');
     if (!is_array($aConfCurrencies)) {
         return array();
     }
     if (defined('OXID_PHP_UNIT')) {
         if (isset(modConfig::$unitMOD) && is_object(modConfig::$unitMOD)) {
             try {
                 $aAltCurrencies = modConfig::getInstance()->getConfigParam('modaCurrencies');
                 if (isset($aAltCurrencies)) {
                     $aConfCurrencies = $aAltCurrencies;
                 }
             } catch (Exception $e) {
                 // if exception is thrown, use default
             }
         }
     }
     // processing currency configuration data
     $aCurrencies = array();
     reset($aConfCurrencies);
     while (list($key, $val) = each($aConfCurrencies)) {
         if ($val) {
             $oCur = new oxStdClass();
             $oCur->id = $key;
             $sCur = explode('@', $val);
             $oCur->name = trim($sCur[0]);
             $oCur->rate = trim($sCur[1]);
             $oCur->dec = trim($sCur[2]);
             $oCur->thousand = trim($sCur[3]);
             $oCur->sign = trim($sCur[4]);
             $oCur->decimal = trim($sCur[5]);
             // change for US version
             if (isset($sCur[6])) {
                 $oCur->side = trim($sCur[6]);
             }
             if (isset($iCurrency) && $key == $iCurrency) {
                 $oCur->selected = 1;
             } else {
                 $oCur->selected = 0;
             }
             $aCurrencies[$key] = $oCur;
         }
         // #861C -  performance, do not load other currencies
         if (!$this->getConfigParam('bl_perfLoadCurrency')) {
             break;
         }
     }
     return $aCurrencies;
 }
 public static function getConfig()
 {
     return modConfig::getInstance();
 }
Exemplo n.º 6
0
 public static function _appendToChain($aExtend)
 {
     // if the chain is still empty and "original" chain is needed
     if (self::$_blOriginal && !count(self::$_aChain)) {
         self::$_aChain = (array) modConfig::getInstance()->getConfigParam("aModules");
     }
     // addping the "extend" chain to the main chain
     foreach ($aExtend as $sParent => $sExtends) {
         if (isset(self::$_aChain[$sParent])) {
             $sExtends = trim(self::$_aChain[$sParent], "& ") . "&" . trim($sExtends, "& ");
         }
         self::$_aChain[$sParent] = $sExtends;
     }
 }
Exemplo n.º 7
0
 /**
  * Converts a string to UTF format.
  *
  * @todo move to separate class instead of static
  *
  * @return array
  */
 protected static function getDbChecksum()
 {
     $myDB = oxDb::getDB();
     $myConfig = modConfig::getInstance();
     $sSelect = 'select GROUP_CONCAT(DISTINCT t.TABLE_NAME) from INFORMATION_SCHEMA.tables as t where t.TABLE_SCHEMA = "' . $myConfig->getConfigParam('dbName') . '" and t.TABLE_NAME not like "oxv_%"';
     $rs = $myDB->execute($sSelect);
     $sSelect = 'CHECKSUM TABLE ' . $rs->fields[0];
     $rs = $myDB->execute($sSelect);
     if ($rs != false && $rs->RecordCount() > 0) {
         while (!$rs->EOF) {
             if (stripos($rs->fields[0], "oxv_") !== 0) {
                 $aChecksum[$rs->fields[0]] = $rs->fields[1];
             }
             $rs->MoveNext();
         }
     }
     return $aChecksum;
 }
 public function testActionSubmit_importSuccess()
 {
     // Config mock
     $oConfig = $this->getMock('oxConfig', array('getUploadedFile'));
     $oConfig->expects($this->once())->method('getUploadedFile')->with('oxpsmodulesconfig_file')->will($this->returnValue(array('error' => '', 'type' => 'application/octet-stream', 'tmp_name' => '/path/to/good_file.json')));
     oxRegistry::set('oxConfig', $oConfig);
     modConfig::setRequestParameter('oxpsmodulesconfig_modules', array('my_module'));
     modConfig::setRequestParameter('oxpsmodulesconfig_settings', array('version' => 1, 'extend' => 1));
     modConfig::setRequestParameter('oxpsmodulesconfig_import', 1);
     // Request validator instance mock
     $oValidator = $this->getMock('oxpsModulesConfigRequestValidator', array('__call', 'validateRequestData', 'validateImportData', 'addErrors'));
     $oValidator->expects($this->once())->method('validateRequestData')->with(array('modules' => array('my_module'), 'settings' => array('version', 'extend'), 'action' => 'import'))->will($this->returnValue(true));
     $oValidator->expects($this->once())->method('validateImportData')->with(array('error' => '', 'type' => 'application/octet-stream', 'tmp_name' => '/path/to/good_file.json'))->will($this->returnValue(true));
     $oValidator->expects($this->never())->method('addErrors');
     oxRegistry::set('oxpsModulesConfigRequestValidator', $oValidator);
     // Configuration data transfer handler mock
     $oConfigTransfer = $this->getMock('oxpsModulesConfigTransfer', array('__call', 'backupToFile', 'setImportDataFromFile', 'importData', 'getImportErrors'));
     $oConfigTransfer->expects($this->once())->method('backupToFile')->with(array('modules' => array('my_module', 'good_extension'), 'settings' => array('version', 'extend', 'files'), 'action' => ''), 'full_backup')->will($this->returnValue(true));
     $oConfigTransfer->expects($this->once())->method('setImportDataFromFile')->with(array('error' => '', 'type' => 'application/octet-stream', 'tmp_name' => '/path/to/good_file.json'));
     $oConfigTransfer->expects($this->once())->method('importData')->with(array('modules' => array('my_module'), 'settings' => array('version', 'extend'), 'action' => 'import'))->will($this->returnValue(true));
     $oConfigTransfer->expects($this->never())->method('getImportErrors');
     oxTestModules::addModuleObject('oxpsModulesConfigTransfer', $oConfigTransfer);
     // Content model mock
     $oContent = $this->getMock('oxpsModulesConfigContent', array('__call', 'getModulesList', 'getSettingsList'));
     $oContent->expects($this->once())->method('getModulesList')->will($this->returnValue(array('my_module' => (object) array('version' => '1.0.0'), 'good_extension' => (object) array('version' => '0.2.5'))));
     $oContent->expects($this->once())->method('getSettingsList')->will($this->returnValue(array('version' => 'Versions', 'extend' => 'Extended classes', 'files' => 'New classes')));
     oxRegistry::set('oxpsModulesConfigContent', $oContent);
     // Module instance mock
     $oModule = $this->getMock('oxpsModulesConfigModule', array('__construct', '__call', 'clearTmp'));
     //$oModule->expects($this->once())->method('clearTmp');
     oxTestModules::addModuleObject('oxpsModulesConfigModule', $oModule);
     $this->SUT->actionSubmit();
     $this->assertSame('import', $this->SUT->getAction());
     $this->assertSame(array('OXPS_MODULESCONFIG_MSG_BACKUP_SUCCESS', 'OXPS_MODULESCONFIG_MSG_IMPORT_SUCCESS'), $this->SUT->getMessages());
 }
Exemplo n.º 9
0
 /**
  * @covers Chromephp_Admin_Main::_getParams
  */
 public function testGetParamsActivDebagAxFilter()
 {
     modConfig::setParameter("editval", array('debugActive' => '1', 'sendData' => '2', 'sAuthorizationText' => '', 'sqlCheck' => '2', 'info' => '1'));
     modConfig::setParameter("filter", array('usermodel' => '0', 'backtrace' => '0', 'search' => '1', 'sSearchText' => 'test1'));
     modConfig::setParameter("sSerchMore", array(0 => 'test2', 1 => 'test3'));
     $oTestClass = $this->getProxyClass('Chromephp_Admin_Main');
     $aReturn = array('debugActive' => '1', 'sendData' => '2', 'sAuthorizationText' => '', 'sqlCheck' => '2', 'info' => '1', 'filter' => array('usermodel' => '0', 'backtrace' => '0', 'search' => '1', 'sSearchText' => 'test1#test2#test3', 'moreFilter' => 1));
     $this->assertSame($oTestClass->UNITgetParams(), $aReturn);
 }
 public function testGenerateModule_allOptionsSet_generateModuleSkeletonWithAllFeatres()
 {
     // Config mock
     modConfig::setRequestParameter('modulegenerator_module_name', 'AllThings');
     modConfig::setRequestParameter('modulegenerator_extend_classes', 'oxbasket' . PHP_EOL . 'oxList');
     modConfig::setRequestParameter('modulegenerator_controllers', 'View' . PHP_EOL . 'Preview');
     modConfig::setRequestParameter('modulegenerator_models', 'Item' . PHP_EOL . 'Model');
     modConfig::setRequestParameter('modulegenerator_lists', 'Model');
     modConfig::setRequestParameter('modulegenerator_widgets', 'Bar' . PHP_EOL . 'Menu');
     modConfig::setRequestParameter('modulegenerator_blocks', '*****@*****.**' . PHP_EOL . '*****@*****.**');
     modConfig::setRequestParameter('modulegenerator_settings', array(0 => array('name' => 'Assoc', 'type' => 'aarr', 'value' => 'a => b' . PHP_EOL . '1 => VAL'), 1 => array('name' => 'Dropdown', 'type' => 'select', 'value' => 'A' . PHP_EOL . 'B' . PHP_EOL . 'C')));
     modConfig::setRequestParameter('modulegenerator_init_version', '1.0.1');
     modConfig::setRequestParameter('modulegenerator_fetch_unit_tests', false);
     //NOTE: This test takes very long.
     modConfig::setRequestParameter('modulegenerator_render_tasks', true);
     modConfig::setRequestParameter('modulegenerator_render_samples', true);
     $this->SUT->init();
     $this->SUT->generateModule();
     $aViewData = $this->SUT->getViewData();
     $this->assertArrayHasKey('sMessage', $aViewData);
     $this->assertSame('OXPS_MODULEGENERATOR_ADMIN_MODULE_MSG_GENERATION_SUCCESS', $aViewData['sMessage']);
     $this->assertArrayHasKey('blError', $aViewData);
     $this->assertFalse($aViewData['blError']);
     // Check module structure
     $this->assertFileExists($this->_getTestPath('modules/test/allthings/metadata.php'));
     // Check metadata content
     include $this->_getTestPath('modules/test/allthings/metadata.php');
     $this->assertTrue(isset($aModule));
     if (isset($aModule)) {
         $this->assertSame(array('id' => 'testallthings', 'title' => array('de' => '[TR - TEST All Things]', 'en' => 'TEST All Things'), 'description' => array('de' => '[TR - TEST All Things Module]', 'en' => 'TEST All Things Module'), 'thumbnail' => 'out/pictures/picture.png', 'version' => '1.0.1', 'author' => 'TEST', 'url' => 'www.example.com', 'email' => '*****@*****.**', 'extend' => array('oxbasket' => 'test/allthings/models/testallthingsoxbasket', 'oxlist' => 'test/allthings/core/testallthingsoxlist'), 'files' => array('testallthingsmodule' => 'test/allthings/core/testallthingsmodule.php', 'testallthingsbar' => 'test/allthings/components/widgets/testallthingsbar.php', 'testallthingsmenu' => 'test/allthings/components/widgets/testallthingsmenu.php', 'testallthingsview' => 'test/allthings/controllers/testallthingsview.php', 'testallthingspreview' => 'test/allthings/controllers/testallthingspreview.php', 'testallthingsitem' => 'test/allthings/models/testallthingsitem.php', 'testallthingsmodel' => 'test/allthings/models/testallthingsmodel.php', 'testallthingsmodellist' => 'test/allthings/models/testallthingsmodellist.php'), 'templates' => array('testallthingsview.tpl' => 'test/allthings/views/pages/testallthingsview.tpl', 'testallthingspreview.tpl' => 'test/allthings/views/pages/testallthingspreview.tpl', 'testallthingsbar.tpl' => 'test/allthings/views/widgets/testallthingsbar.tpl', 'testallthingsmenu.tpl' => 'test/allthings/views/widgets/testallthingsmenu.tpl'), 'blocks' => array(array('template' => 'page.tpl', 'block' => 'block', 'file' => 'views/blocks/testallthings_block.tpl'), array('template' => 'layout.tpl', 'block' => 'footer', 'file' => 'views/blocks/testallthings_footer.tpl')), 'settings' => array(array('group' => 'testAllThingsSettings', 'name' => 'testAllThingsAssoc', 'type' => 'aarr', 'value' => array('a' => 'b', '1' => 'VAL')), array('group' => 'testAllThingsSettings', 'name' => 'testAllThingsDropdown', 'type' => 'select', 'value' => 'A', 'constrains' => 'A|B|C')), 'events' => array('onActivate' => 'testAllThingsModule::onActivate', 'onDeactivate' => 'testAllThingsModule::onDeactivate')), $aModule);
     }
 }
Exemplo n.º 11
0
 public function cleanup()
 {
     modConfig::getInstance()->remClassFunction('getDB');
     self::$unitMOD = null;
     parent::cleanup();
 }
Exemplo n.º 12
0
 /**
  * @covers chromephp_admin_perform::startPerformTest
  */
 public function testStartPerformTest()
 {
     oxTestModules::addFunction('testPerformance', 'changePerformFile', '{ return true; }');
     $aArrayTestSufix = array(1 => 'start', 2 => 'list', 3 => 'details');
     $sTestUrl = 'http://www.test.com/';
     $sTestComment = 'Test Comment';
     $iIterator = 3;
     $aArrayTest = array();
     for ($iTest = 1; $iTest <= $iIterator; $iTest++) {
         $aArrayTest[$iTest] = $sTestUrl;
     }
     modConfig::setParameter("aUrls", $aArrayTest);
     modConfig::setParameter("comment", $sTestComment);
     $oTestClass = new chromephp_admin_perform();
     $this->assertNull($oTestClass->startPerformTest());
     $aViewData = $oTestClass->getViewData();
     $aResultLinks = $aViewData['aUrlsIframe'];
     for ($iTest = 1; $iTest <= $iIterator; $iTest++) {
         $this->assertSame($aResultLinks[$iTest], $sTestUrl . '?test=' . $aArrayTestSufix[$iTest], 'Result Url is not a same');
     }
     $this->assertSame(3, count($aResultLinks), 'Only 3 Link are allowed');
     $this->assertTrue($aViewData['bPerform'], 'bPerform is not a True');
     $this->assertSame($aViewData['comment'], $sTestComment, 'Coment ist no a same');
 }
Exemplo n.º 13
0
 /**
  * Checks which tables of the db changed and then restores these tables.
  *
  * Uses dump file '/tmp/tmp_db_dump' for comparison and restoring.
  *
  * @param integer $iMode   Maintenance mode
  * @param integer $iOutput Outout type
  *
  * @return integer changet
  */
 public function restoreDB($iMode = MAINTENANCE_SINGLEROWS, $iOutput = MAINTENANCE_MODE_ONLYRESET)
 {
     // php 523 error
     modConfig::getInstance()->cleanup();
     modConfig::$unitMOD = null;
     $time = microtime(true);
     $myConfig = oxConfig::getInstance();
     $sDbName = oxConfig::getInstance()->getConfigParam('dbName');
     $this->_oDBDump = file_get_contents('/tmp/tmp_db_dump_' . $sDbName);
     $this->_oDBDump = unserialize($this->_oDBDump);
     $myDB = oxDb::getDb();
     $myDB->SetFetchMode(ADODB_FETCH_NUM);
     $rs = $myDB->Query("SHOW TABLES");
     $myDB->SetFetchMode(ADODB_FETCH_ASSOC);
     $sChanges = "";
     //current table
     $sTable = "";
     //list of sql commands to execute;
     $aSQL = array();
     $aInsert = array();
     $aTableInsert = array();
     while (!$rs->EOF) {
         $sTable = $rs->fields[0];
         $rs->moveNext();
         if (strpos($sTable, "oxv_") === false) {
             $aChangesCounter[$sTable] = 0;
             if (!isset($this->_oDBDump[$sTable])) {
                 $sChanges .= "Table " . $sTable . " was added\n";
                 $aChangesCounter[$sTable]++;
                 //delete this table
                 $aSQL[] = "DROP TABLE " . $sTable . "";
                 continue;
             }
             $rs2 = $myDB->Query("Select * from " . $sTable);
             if ($rs2 && $rs2->RecordCount() > 0) {
                 $rowCount = 1;
                 while ($aRow = $rs2->fetchRow()) {
                     $oxid = $aRow['OXID'];
                     $blNoOXID = false;
                     if ($oxid == "") {
                         // the tables without oxid,
                         $oxid = $rowCount++;
                         $blNoOXID = true;
                     }
                     if (!isset($this->_oDBDump[$sTable][$oxid])) {
                         $aChangesCounter[$sTable]++;
                         if ($iMode == MAINTENANCE_SINGLEROWS && !$blNoOXID) {
                             $sChanges .= "In table " . $sTable . " a record was added\n";
                             $aSQL[] = "DELETE FROM " . $sTable . " WHERE OXID = '" . $oxid . "'";
                             $aInsert[$sTable][] = $oxid;
                             //mark this row as existing
                             $this->_oDBDump[$sTable][$oxid]['_EXISTS_'] = true;
                             continue;
                             //with next row
                         } else {
                             if ($iMode == MAINTENANCE_WHOLETABLES || $blNoOXID) {
                                 //in single table mode tables without oxid are handeld like in whole table mode
                                 $sChanges .= "In table " . $sTable . " record(s)was(were) added\n";
                                 $aSQL[] = "DELETE FROM " . $sTable;
                                 $aTableInsert[] = $sTable;
                                 //mark this table as existing
                                 $this->_oDBDump[$sTable]['_EXISTS_'] = true;
                                 //skip rest of table
                                 continue 2;
                             }
                         }
                     } else {
                         //check only if the record already existed
                         foreach ($aRow as $sColumn => $sEntry) {
                             if ($sColumn == "OXVARVALUE") {
                                 //special handeling of blob values of oxconfig
                                 $sEntry = oxUtils::getInstance()->strMan($sEntry, $myConfig->getConfigParam('sConfigKey'));
                             }
                             if (!isset($this->_oDBDump[$sTable][$oxid][$sColumn])) {
                                 //a new colum
                                 $aChangesCounter[$sTable]++;
                                 if ($iMode == MAINTENANCE_SINGLEROWS && !$blNoOXID) {
                                     $sChanges .= "In table " . $sTable . " and record oxid: " . $oxid . " column " . $sColumn . " was added\n";
                                     $aSQL[] = "DELETE FROM " . $sTable . " WHERE OXID = '" . $oxid . "'";
                                     $aInsert[$sTable][] = $oxid;
                                     //mark this row as existing
                                     $this->_oDBDump[$sTable][$oxid]['_EXISTS_'] = true;
                                     //skip rest of row
                                     continue 2;
                                 } else {
                                     if ($iMode == MAINTENANCE_WHOLETABLES || $blNoOXID) {
                                         $sChanges .= "In table " . $sTable . " column(s) {$sColumn} was(were) added\n";
                                         $aSQL[] = "DELETE FROM " . $sTable;
                                         $aTableInsert[] = $sTable;
                                         //mark this table as existing
                                         $this->_oDBDump[$sTable]['_EXISTS_'] = true;
                                         //skip rest of table
                                         continue 3;
                                     }
                                 }
                             } elseif (strcmp($this->_oDBDump[$sTable][$oxid][$sColumn], $sEntry) != 0) {
                                 //changed value
                                 $aChangesCounter[$sTable]++;
                                 if ($iMode == MAINTENANCE_SINGLEROWS && !$blNoOXID) {
                                     $sChanges .= "In table " . $sTable . ", record oxid: " . $oxid . " and column " . $sColumn . " the value changed from: " . $this->_oDBDump[$sTable][$oxid][$sColumn] . " to: " . $sEntry . "\n";
                                     $aSQL[] = "DELETE FROM " . $sTable . " WHERE OXID = '" . $oxid . "'";
                                     $aInsert[$sTable][] = $oxid;
                                     //mark this row as existing
                                     $this->_oDBDump[$sTable][$oxid]['_EXISTS_'] = true;
                                     //skip rest of row
                                     continue 2;
                                 } elseif ($iMode == MAINTENANCE_WHOLETABLES || $blNoOXID) {
                                     $sChanges .= "In table " . $sTable . ", record values changed\n";
                                     $aSQL[] = "DELETE FROM " . $sTable;
                                     $aTableInsert[] = $sTable;
                                     //mark this table as existing
                                     $this->_oDBDump[$sTable]['_EXISTS_'] = true;
                                     //skip rest of table
                                     continue 3;
                                 }
                             }
                         }
                     }
                     $this->_oDBDump[$sTable][$oxid]['_EXISTS_'] = true;
                 }
             }
             //checking for removed rows
             foreach ($this->_oDBDump[$sTable] as $oxid => $aEntry) {
                 if ($oxid == '_EXISTS_') {
                     if ($iMode == MAINTENANCE_WHOLETABLES) {
                         //everything is fine, whole table will be inserted
                         continue;
                     }
                 } else {
                     if (!isset($aEntry['_EXISTS_'])) {
                         $sChanges .= "In table " . $sTable . ", record oxid " . $oxid . " was removed (" . $aEntry . ")\n";
                         $aChangesCounter[$sTable]++;
                         //add the record again, same for both modes
                         $aInsert[$sTable][] = $oxid;
                     }
                 }
             }
         }
     }
     //add the restore sql scripts
     foreach ($aInsert as $sTable => $aOxid) {
         foreach ($aOxid as $k => $oxid) {
             $aSQL[] = $this->_oDBDump[$sTable][$oxid]["_sql_"];
         }
     }
     //add the whole tables (for MAINTENANCE_WHOLETABLES mode)
     foreach ($aTableInsert as $k => $sTable) {
         foreach ($this->_oDBDump[$sTable] as $oxid => $aVals) {
             if ($oxid == '_EXISTS_') {
                 continue;
             }
             $aSQL[] = $aVals["_sql_"];
         }
     }
     if ($iOutput == MAINTENANCE_MODE_ONLYOUTPUT || $iOutput == MAINTENANCE_MODE_RESETANDOUTPUT) {
         $sChanges .= "\n\n";
         $sChanges .= "DB RESET EXECUTION. start time: " . date('Y-m-d H:i:s');
         $sChanges .= "\n";
         $i = 0;
         foreach ($aChangesCounter as $sTable => $iChanges) {
             if ($iChanges > 0) {
                 $sChanges .= "In table " . $sTable . " are " . $iChanges . " changes!\n";
                 $i += $iChanges;
             }
         }
         $sChanges .= "\nIn total there are " . $i . " changes!!!\n\n\n\n";
         if ($i > 0) {
             file_put_contents('dbchanges_log.txt', $sChanges . var_export($aSQL, 1) . var_export($this->_oDBDump, 1), FILE_APPEND);
         }
     }
     if ($iOutput == MAINTENANCE_MODE_ONLYRESET || $iOutput == MAINTENANCE_MODE_RESETANDOUTPUT) {
         //now execute delete and drop statements and the insert statements (at the end)
         foreach ($aSQL as $k => $v) {
             $myDB->Query($v);
         }
     }
     $myDB->SetFetchMode(ADODB_FETCH_NUM);
     //echo(" T:".(microtime(true)-$time));
     return $aChangesCounter;
 }
 public function testBackupToFile()
 {
     // Config mock
     $oConfig = $this->getMock('oxConfig', array('getVersion', 'getEdition', 'getShopId'));
     $oConfig->expects($this->once())->method('getVersion')->will($this->returnValue('5.1.0'));
     $oConfig->expects($this->once())->method('getEdition')->will($this->returnValue('EE'));
     $oConfig->expects($this->once())->method('getShopId')->will($this->returnValue(1));
     modConfig::getInstance()->setConfigParam('sShopDir', '/var/www/my_shop/');
     // Configuration storage mock
     $oConfigStorage = $this->getMock('oxpsModulesConfigStorage', array('__call', 'load'));
     $oConfigStorage->expects($this->at(0))->method('load')->with('mymodule', 'version')->will($this->returnValue('1.1.0'));
     $oConfigStorage->expects($this->at(1))->method('load')->with('mymodule', 'extend')->will($this->returnValue(array()));
     $oConfigStorage->expects($this->at(2))->method('load')->with('mymodule', 'files')->will($this->returnValue(array('mymoduleitem' => 'my/module/models/mymoduleitem.php')));
     $oConfigStorage->expects($this->at(3))->method('load')->with('othermodule', 'version')->will($this->returnValue('0.1.0'));
     $oConfigStorage->expects($this->at(4))->method('load')->with('othermodule', 'extend')->will($this->returnValue(array('basket' => 'other/module/controllers/othermodulebasket', 'oxarticle' => 'other/module/models/othermoduleoxarticle')));
     $oConfigStorage->expects($this->at(5))->method('load')->with('othermodule', 'files')->will($this->returnValue(array()));
     oxRegistry::set('oxpsModulesConfigStorage', $oConfigStorage);
     $this->SUT->expects($this->exactly(2))->method('getConfig')->will($this->returnValue($oConfig));
     $this->SUT->expects($this->never())->method('_jsonDownload');
     $this->SUT->expects($this->once())->method('_touchBackupsDir')->with('/var/www/my_shop/export/modules_config/');
     $this->SUT->expects($this->once())->method('_jsonBackup')->with($this->stringEndsWith('.my_backup.json'), $this->equalTo(array('_OXID_ESHOP_MODULES_CONFIGURATION_' => array('sShopVersion' => '5.1.0', 'sShopEdition' => 'EE', 'sShopId' => 1, 'aModules' => array('mymodule' => array('version' => '1.1.0', 'extend' => array(), 'files' => array('mymoduleitem' => 'my/module/models/mymoduleitem.php')), 'othermodule' => array('version' => '0.1.0', 'extend' => array('basket' => 'other/module/controllers/othermodulebasket', 'oxarticle' => 'other/module/models/othermoduleoxarticle'), 'files' => array()))))))->will($this->returnValue(888));
     $this->assertSame(888, $this->SUT->backupToFile(array('modules' => array('mymodule', 'othermodule'), 'settings' => array('version', 'extend', 'files')), 'my_backup'));
 }
Exemplo n.º 15
0
 /**
  * @covers chromephp_admin_file::save
  */
 public function testSave()
 {
     modConfig::setParameter("editval", array('test' => 6, 'test2' => 6));
     $oView = new chromephp_admin_file();
     $this->assertNull($oView->save());
 }