/** * test config add * * @return void */ public function testAdd() { $conn = m::mock('Xpressengine\\Database\\VirtualConnectionInterface'); $configManager = m::mock('Xpressengine\\Config\\ConfigManager'); $configManager->shouldReceive('add'); $handler = new ConfigHandler($conn, $configManager); $config = m::mock('Xpressengine\\Config\\ConfigEntity'); $config->shouldReceive('get')->with('group')->andReturn('group'); $config->shouldReceive('get')->with('id')->andReturn('id'); $config->shouldReceive('getPureAll')->andReturn([]); $handler->add($config); }
/** * DynamicField 생성 * * ConfigManager 를 이용해 설정 정보를 저장 * * FieldTypeManager 로 Dynamic Field Table 생성 * * @param ConfigEntity $config insert config entity * @param ColumnEntity $column join column entity * @return void */ public function create(ConfigEntity $config, ColumnEntity $column = null) { $group = $config->get('group'); $id = $config->get('id'); if ($group == null || $id == null) { throw new Exceptions\InvalidConfigException(); } if ($this->configHandler->get($group, $id) !== null) { throw new Exceptions\AlreadyExistException(); } if ($this->configHandler->parent($group) == null) { $this->configHandler->setParent($group); } if ($column === null) { $column = $this->getDefaultJoinColumn(); } $config->set('joinColumnName', $column->name); $this->connection->beginTransaction(); $this->configHandler->add($config); $type = $this->registerHandler->getType($this, $config->get('typeId')); $type->setConfig($config); $type->create($column); $this->connection->commit(); }