Example #1
0
 /**
  * Проверяем работу метода CConfig::selectAll, он должен вернуть объекты CConfigSchema 
  */
 public function testSelect()
 {
     $schema = CConfig::createSchema('test2');
     $schema->updateSchema('test2', 'Title');
     // Проверяем кол-во схем
     $list = CConfig::selectAll();
     $this->assertEquals(2, sizeof($list));
     $this->assertEquals(true, $list[0] instanceof CConfigSchema);
 }
Example #2
0
 /**
  * Данный метод обрабатывает форму создания конфига
  * @param string $name
  * @param string $title
  */
 public function create($name, $title)
 {
     try {
         $schema = CConfig::createSchema($name);
         $schema->updateSchema($name, $title);
         $this->addAlert(sprintf('Конфиг "%s" создан', $name));
     } catch (Exception $e) {
         $this->addError($e->getMessage());
     }
     $this->jumpBack();
 }
Example #3
0
 public function testCreate()
 {
     $old = $this->getCounts();
     //
     $schema = CConfig::createSchema('test2');
     // Проверяем, что схема была создана и обозначена в таблице
     $schemaCount = DB::getField('select count(*) as `count` from ' . CCONFIG_SCHEMA_TABLE, 'count');
     $this->assertEquals(2, $schemaCount);
     $schema->addControl('name', 'inputField', 'Имя');
     $schema->addControl('name2', 'inputField', 'Имя2');
     $schema->setTabSheets(array('Данные' => 'name'));
     // Проверяем кол-во записей в обоих таблицах
     $result = $this->getCounts();
     $this->assertEquals($result, array('tabcount' => $old['tabcount'] + 1, 'controlcount' => $old['controlcount'] + 2));
 }
Example #4
0
}
Restorator::restore();
\SystemRegisterSample::createCache();
TestsHelper::dbFixture(ACL_TABLE, array());
ACL::create(ApiOperation::RightName);
// user record
TestsHelper::dbFixture(USERS_TABLE, array(array('login' => 'login', 'password' => passwordColumn::hash('testtest')), array('login' => 'guest', 'password' => passwordColumn::hash('testtest'))));
// grant user permission
$user = UserAccount::getByLogin('login');
ACL::grant(ApiOperation::RightName, $user->obj_rights->getEntity());
\UsersLogin::login('login', 'testtest');
// base logs
TestsHelper::dbFixture(Log::getTableName(), array(array('name' => 'Log1', 'critical' => 0, 'enable_logging' => 1), array('name' => 'Log2', 'critical' => 1, 'enable_logging' => 1)));
// base records
// - [different by user_id]
// - [different by date]
// - [different by content]
TestsHelper::dbFixture(Record::getTableName(), array(array('log_id' => 1, 'date' => '2001-01-01 00:00:00', 'short' => 'short log', 'full' => 'full_log', 'user_id' => 1, 'user_login' => 'login'), array('log_id' => 2, 'date' => '2001-01-02 00:00:00', 'short' => 'short log', 'full' => 'full_log', 'user_id' => 1, 'user_login' => 'login'), array('log_id' => 1, 'date' => '2001-01-03 00:00:00', 'short' => 'short log', 'full' => 'full_log')));
// Create custom config if it exists
$schemaName = 'Audit.CriticalEventName';
try {
    $config = \CConfig::getSchema($schemaName);
    $config->delete();
} catch (\Exception $e) {
} finally {
    $config = \CConfig::createSchema($schemaName);
    $config->addControl('to', 'inputfield', 'Получатели письма', array(), '*****@*****.**');
    $config->addControl('subject', 'inputfield', 'Тема письма', array(), 'Email Subject');
    $config->addControl('content', 'htmlfield', 'Шаблон письма', array(), 'Message body');
    $config->updateSchema($schemaName, 'Шаблон письма-оповещения о наступлении критического события аудита');
}