public function testCheckEngineCompatibility() { $o = new Db_Object_Builder('Page'); $this->assertTrue($o->checkEngineCompatibility('myisam')); $this->assertTrue($o->checkEngineCompatibility('innodb')); $this->assertTrue(is_array($o->checkEngineCompatibility('memory'))); $invalidEngine = false; try { $o->checkEngineCompatibility('ksdhuis'); } catch (Exception $e) { $invalidEngine = true; } $this->assertTrue($invalidEngine); }
protected function _updateObject($recordId, $name, array $data) { $objectConfigPath = $this->_configMain->get('object_configs') . $recordId . '.php'; if ($this->_configMain->get('allow_externals')) { $manager = new Db_Object_Manager(); $externalExpert = $manager->getExternalsExpert(); if ($externalExpert->hasObject($recordId)) { $objectConfigPath = $externalExpert->getObjectPath($recordId); } } if (!is_writable($objectConfigPath)) { Response::jsonError($this->_lang->CANT_WRITE_FS); } /* * Rename object */ if ($recordId != $name) { $this->_renameObject($recordId, $name); } try { $config = Db_Object_Config::getInstance($name); } catch (Exception $e) { Response::jsonError($this->_lang->INVALID_VALUE); } $builder = new Db_Object_Builder($name); /* * Rename Db Table */ if ($config->get('table') !== $data['table']) { if ($builder->tableExists($data['table'], true)) { Response::jsonError($this->_lang->FILL_FORM, array(array('id' => 'table', 'msg' => $this->_lang->SB_UNIQUE))); } if (!$builder->renameTable($data['table'])) { Response::jsonError($this->_lang->CANT_RENAME_TABLE); } } /* * Check and apply changes for DB Table engine */ if ($config->get('engine') !== $data['engine']) { $err = $builder->checkEngineCompatibility($data['engine']); if ($err !== true) { Response::jsonError($this->_lang->CANT_EXEC . ' ', $err); } if (!$builder->changeTableEngine($data['engine'])) { $errors = $builder->getErrors(); if (!empty($errors)) { $errors = implode(' <br>', $errors); } Response::jsonError($this->_lang->CANT_EXEC . ' ' . $errors); } } $data['fields'] = $config->getFieldsConfig(false); $config->setData($data); $config->setObjectTitle($data['title']); if (!$config->save()) { Response::jsonError($this->_lang->CANT_WRITE_FS); } Response::jsonSuccess(); }