public function testRenameField() { $AddedValue = 'scalar value'; self::$DI['record_1']->set_metadatas([['meta_id' => null, 'meta_struct_id' => $this->object_mono->get_id(), 'value' => $AddedValue]]); $this->object_mono->set_name('Bonobo yoyo')->save(); $data = self::$DI['record_1']->get_caption()->get_field('Bonoboyoyo')->get_values(); $value = array_pop($data); $this->assertEquals($value->getValue(), $AddedValue); }
private function updateFieldWithData(Application $app, \databox_field $field, array $data) { $field->set_name($data['name'])->set_thumbtitle($data['thumbtitle'])->set_tag(\databox_field::loadClassFromTagName($data['tag']))->set_business($data['business'])->set_aggregable($data['aggregable'])->set_indexable($data['indexable'])->set_required($data['required'])->set_separator($data['separator'])->set_readonly($data['readonly'])->set_type($data['type'])->set_tbranch($data['tbranch'])->set_report($data['report'])->setVocabularyControl(null)->setVocabularyRestricted(false); foreach ($data['labels'] as $code => $label) { $field->set_label($code, $label); } if (isset($data['sorter'])) { $field->set_position($data['sorter']); } try { $vocabulary = VocabularyController::get($app, $data['vocabulary-type']); $field->setVocabularyControl($vocabulary); $field->setVocabularyRestricted($data['vocabulary-restricted']); } catch (\InvalidArgumentException $e) { } if ('' !== ($dcesElement = (string) $data['dces-element'])) { $class = sprintf('\\databox_Field_DCES_%s', $dcesElement); if (!class_exists($class)) { throw new BadRequestHttpException(sprintf('DCES element %s does not exist.', $dcesElement)); } $field->set_dces_element(new $class()); } }