示例#1
0
 /**
  * Tests email field.
  */
 function testEmailField()
 {
     // Create a field with settings to validate.
     $field_name = Unicode::strtolower($this->randomMachineName());
     $this->fieldStorage = FieldStorageConfig::create(array('field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'email'));
     $this->fieldStorage->save();
     $this->field = FieldConfig::create(['field_storage' => $this->fieldStorage, 'bundle' => 'entity_test']);
     $this->field->save();
     // Create a form display for the default form mode.
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => 'email_default', 'settings' => array('placeholder' => '*****@*****.**')))->save();
     // Create a display for the full view mode.
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($field_name, array('type' => 'email_mailto'))->save();
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget found.');
     $this->assertRaw('placeholder="*****@*****.**"');
     // Submit a valid email address and ensure it is accepted.
     $value = '*****@*****.**';
     $edit = array("{$field_name}[0][value]" => $value);
     $this->drupalPostForm(NULL, $edit, t('Save'));
     preg_match('|entity_test/manage/(\\d+)|', $this->url, $match);
     $id = $match[1];
     $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
     $this->assertRaw($value);
     // Verify that a mailto link is displayed.
     $entity = EntityTest::load($id);
     $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
     $content = $display->build($entity);
     $this->setRawContent(\Drupal::service('renderer')->renderRoot($content));
     $this->assertLinkByHref('mailto:test@example.com');
 }
 /**
  * Checks block edit functionality.
  */
 public function testBlockFields()
 {
     $this->drupalLogin($this->adminUser);
     $this->blockType = $this->createBlockContentType('link');
     // Create a field with settings to validate.
     $this->fieldStorage = entity_create('field_storage_config', array('field_name' => drupal_strtolower($this->randomMachineName()), 'entity_type' => 'block_content', 'type' => 'link', 'cardinality' => 2));
     $this->fieldStorage->save();
     $this->field = entity_create('field_config', array('field_storage' => $this->fieldStorage, 'bundle' => 'link', 'settings' => array('title' => DRUPAL_OPTIONAL)));
     $this->field->save();
     entity_get_form_display('block_content', 'link', 'default')->setComponent($this->fieldStorage->getName(), array('type' => 'link_default'))->save();
     entity_get_display('block_content', 'link', 'default')->setComponent($this->fieldStorage->getName(), array('type' => 'link', 'label' => 'hidden'))->save();
     // Create a block.
     $this->drupalGet('block/add/link');
     $edit = array('info[0][value]' => $this->randomMachineName(8), $this->fieldStorage->getName() . '[0][url]' => 'http://example.com', $this->fieldStorage->getName() . '[0][title]' => 'Example.com');
     $this->drupalPostForm(NULL, $edit, t('Save'));
     $block = entity_load('block_content', 1);
     $url = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . \Drupal::config('system.theme')->get('default');
     // Place the block.
     $instance = array('id' => drupal_strtolower($edit['info[0][value]']), 'settings[label]' => $edit['info[0][value]'], 'region' => 'sidebar_first');
     $this->drupalPostForm($url, $instance, t('Save block'));
     // Navigate to home page.
     $this->drupalGet('<front>');
     $this->assertLinkByHref('http://example.com');
     $this->assertText('Example.com');
 }
 /**
  * Tests boolean field.
  */
 function testBooleanField()
 {
     $on = $this->randomMachineName();
     $off = $this->randomMachineName();
     $label = $this->randomMachineName();
     // Create a field with settings to validate.
     $field_name = drupal_strtolower($this->randomMachineName());
     $this->field_storage = FieldStorageConfig::create(array('field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'boolean', 'settings' => array('on_label' => $on, 'off_label' => $off)));
     $this->field_storage->save();
     $this->field = FieldConfig::create(array('field_name' => $field_name, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', 'label' => $label, 'required' => TRUE));
     $this->field->save();
     // Create a form display for the default form mode.
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => 'boolean_checkbox'))->save();
     // Create a display for the full view mode.
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($field_name, array('type' => 'boolean'))->save();
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[value]", '', 'Widget found.');
     $this->assertRaw($on);
     // Submit and ensure it is accepted.
     $edit = array("{$field_name}[value]" => 1);
     $this->drupalPostForm(NULL, $edit, t('Save'));
     preg_match('|entity_test/manage/(\\d+)|', $this->url, $match);
     $id = $match[1];
     $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
     // Verify that boolean value is displayed.
     $entity = entity_load('entity_test', $id);
     $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
     $content = $display->build($entity);
     $this->drupalSetContent(drupal_render($content));
     $this->assertRaw('<div class="field-item">' . $on . '</div>');
     // Test the display_label option.
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => 'boolean_checkbox', 'settings' => array('display_label' => TRUE)))->save();
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[value]", '', 'Widget found.');
     $this->assertNoRaw($on);
     $this->assertText($this->field->label());
     // Go to the form display page and check if the default settings works as
     // expected.
     $fieldEditUrl = 'entity_test/structure/entity_test/form-display';
     $this->drupalGet($fieldEditUrl);
     // Click on the widget settings button to open the widget settings form.
     $this->drupalPostAjaxForm(NULL, array(), $field_name . "_settings_edit");
     $this->assertText('Use field label instead of the "On label" as label', t('Display setting checkbox available.'));
     // Enable setting.
     $edit = array('fields[' . $field_name . '][settings_edit_form][settings][display_label]' => 1);
     $this->drupalPostAjaxForm(NULL, $edit, $field_name . "_plugin_settings_update");
     $this->drupalPostForm(NULL, NULL, 'Save');
     // Go again to the form display page and check if the setting
     // is stored and has the expected effect.
     $this->drupalGet($fieldEditUrl);
     $this->assertText('Use field label: Yes', 'Checking the display settings checkbox updated the value.');
     $this->drupalPostAjaxForm(NULL, array(), $field_name . "_settings_edit");
     $this->assertText('Use field label instead of the "On label" as label', t('Display setting checkbox is available'));
     $this->assertFieldByXPath('*//input[@id="edit-fields-' . $field_name . '-settings-edit-form-settings-display-label" and @value="1"]', TRUE, t('Display label changes label of the checkbox'));
     // Test the boolean field settings.
     $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field_name . '/storage');
     $this->assertFieldById('edit-field-storage-settings-on-label', $on);
     $this->assertFieldById('edit-field-storage-settings-off-label', $off);
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->container->get('router.builder')->rebuild();
     $this->fieldStorageDefinition = array('field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'list_integer', 'cardinality' => 1, 'settings' => array('allowed_values' => array(1 => 'One', 2 => 'Two', 3 => 'Three')));
     $this->fieldStorage = FieldStorageConfig::create($this->fieldStorageDefinition);
     $this->fieldStorage->save();
     $this->field = FieldConfig::create(['field_storage' => $this->fieldStorage, 'bundle' => 'entity_test']);
     $this->field->save();
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($this->fieldName, array('type' => 'options_buttons'))->save();
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installSchema('system', array('router'));
     $this->fieldStorageDefinition = array('field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'list_integer', 'cardinality' => 1, 'settings' => array('allowed_values' => array(1 => 'One', 2 => 'Two', 3 => 'Three')));
     $this->fieldStorage = entity_create('field_storage_config', $this->fieldStorageDefinition);
     $this->fieldStorage->save();
     $this->field = entity_create('field_config', array('field_storage' => $this->fieldStorage, 'bundle' => 'entity_test'));
     $this->field->save();
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($this->fieldName, array('type' => 'options_buttons'))->save();
 }
示例#6
0
 /**
  * Tests URI field.
  */
 public function testUriField()
 {
     $label = $this->randomMachineName();
     // Create a field with settings to validate.
     $field_name = Unicode::strtolower($this->randomMachineName());
     $this->fieldStorage = FieldStorageConfig::create(['field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'uri']);
     $this->fieldStorage->save();
     $this->field = FieldConfig::create(['field_name' => $field_name, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', 'label' => $label, 'required' => TRUE, 'settings' => ['size' => 123, 'placeholder' => '']]);
     $this->field->save();
     // Create a form display for the default form mode.
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, ['type' => 'uri'])->save();
 }
示例#7
0
 /**
  * Creates a date test field.
  */
 protected function createField()
 {
     $field_name = Unicode::strtolower($this->randomMachineName());
     $type = $this->getTestFieldType();
     $widget_type = $formatter_type = $type . '_default';
     $this->fieldStorage = FieldStorageConfig::create(['field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => $type, 'settings' => ['datetime_type' => DateRangeItem::DATETIME_TYPE_DATE]]);
     $this->fieldStorage->save();
     $this->field = FieldConfig::create(['field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', 'required' => TRUE]);
     $this->field->save();
     EntityFormDisplay::load('entity_test.entity_test.default')->setComponent($field_name, ['type' => $widget_type])->save();
     $this->displayOptions = ['type' => $formatter_type, 'label' => 'hidden', 'settings' => ['format_type' => 'medium'] + $this->defaultSettings];
     EntityViewDisplay::create(['targetEntityType' => $this->field->getTargetEntityTypeId(), 'bundle' => $this->field->getTargetBundle(), 'mode' => 'full', 'status' => TRUE])->setComponent($field_name, $this->displayOptions)->save();
 }
 protected function setUp()
 {
     parent::setUp();
     $web_user = $this->drupalCreateUser(array('access content', 'view test entity', 'administer entity_test content', 'administer content types', 'administer node fields'));
     $this->drupalLogin($web_user);
     // Create a field with settings to validate.
     $field_name = Unicode::strtolower($this->randomMachineName());
     $this->fieldStorage = entity_create('field_storage_config', array('field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'datetime', 'settings' => array('datetime_type' => 'date')));
     $this->fieldStorage->save();
     $this->field = entity_create('field_config', array('field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', 'required' => TRUE));
     $this->field->save();
     entity_get_form_display($this->field->entity_type, $this->field->bundle, 'default')->setComponent($field_name, array('type' => 'datetime_default'))->save();
     $this->displayOptions = array('type' => 'datetime_default', 'label' => 'hidden', 'settings' => array('format_type' => 'medium'));
     entity_get_display($this->field->entity_type, $this->field->bundle, 'full')->setComponent($field_name, $this->displayOptions)->save();
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('entity_test');
     $this->installEntitySchema('user');
     $this->installConfig(['system']);
     $this->installSchema('system', ['sequences', 'key_value']);
     // Add a datetime range field.
     $this->fieldStorage = FieldStorageConfig::create(['field_name' => Unicode::strtolower($this->randomMachineName()), 'entity_type' => 'entity_test', 'type' => 'daterange', 'settings' => ['datetime_type' => DateTimeItem::DATETIME_TYPE_DATE]]);
     $this->fieldStorage->save();
     $this->field = FieldConfig::create(['field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', 'required' => TRUE]);
     $this->field->save();
     $display_options = ['type' => 'daterange_default', 'label' => 'hidden', 'settings' => ['format_type' => 'fallback', 'separator' => 'UNTRANSLATED']];
     EntityViewDisplay::create(['targetEntityType' => $this->field->getTargetEntityTypeId(), 'bundle' => $this->field->getTargetBundle(), 'mode' => 'default', 'status' => TRUE])->setComponent($this->fieldStorage->getName(), $display_options)->save();
 }
示例#10
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Create content type with unlimited text field.
     $this->nodeType = $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
     // Create the unlimited text field.
     $this->fieldName = 'field_views_testing_group_rows';
     $this->fieldStorage = FieldStorageConfig::create(['field_name' => $this->fieldName, 'entity_type' => 'node', 'type' => 'text', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED]);
     $this->fieldStorage->save();
     // Create an instance of the text field on the content type.
     $this->field = FieldConfig::create(['field_storage' => $this->fieldStorage, 'bundle' => $this->nodeType->id()]);
     $this->field->save();
     $edit = ['title' => $this->randomMachineName(), $this->fieldName => ['a', 'b', 'c']];
     $this->drupalCreateNode($edit);
 }
示例#11
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installConfig(array('language'));
     $this->fieldName = Unicode::strtolower($this->randomMachineName());
     $this->entityType = 'entity_test';
     $this->fieldStorageDefinition = array('field_name' => $this->fieldName, 'entity_type' => $this->entityType, 'type' => 'test_field', 'cardinality' => 4);
     $this->fieldStorage = FieldStorageConfig::create($this->fieldStorageDefinition);
     $this->fieldStorage->save();
     $this->fieldDefinition = array('field_storage' => $this->fieldStorage, 'bundle' => 'entity_test');
     $this->field = FieldConfig::create($this->fieldDefinition);
     $this->field->save();
     for ($i = 0; $i < 3; ++$i) {
         ConfigurableLanguage::create(array('id' => 'l' . $i, 'label' => $this->randomString()))->save();
     }
 }
 protected function setUp()
 {
     parent::setUp();
     $this->installConfig(array('language'));
     $this->field_name = drupal_strtolower($this->randomMachineName());
     $this->entity_type = 'entity_test';
     $this->field_storage_definition = array('field_name' => $this->field_name, 'entity_type' => $this->entity_type, 'type' => 'test_field', 'cardinality' => 4, 'translatable' => TRUE);
     $this->fieldStorage = entity_create('field_storage_config', $this->field_storage_definition);
     $this->fieldStorage->save();
     $this->field_definition = array('field_storage' => $this->fieldStorage, 'bundle' => 'entity_test');
     $this->field = entity_create('field_config', $this->field_definition);
     $this->field->save();
     for ($i = 0; $i < 3; ++$i) {
         ConfigurableLanguage::create(array('id' => 'l' . $i, 'label' => $this->randomString()))->save();
     }
 }
示例#13
0
 /**
  * Creates a geofield field storage and field.
  *
  * @param string $entity_type
  *   Entity type for which the field should be created.
  */
 protected function createField($entity_type)
 {
     // Create a field .
     $this->fieldStorage = entity_create('field_storage_config', array('field_name' => 'geofield_field', 'entity_type' => $entity_type, 'type' => 'geofield', 'settings' => array('backend' => 'geofield_backend_default')));
     $this->fieldStorage->save();
     $this->field = entity_create('field_config', array('field_storage' => $this->fieldStorage, 'bundle' => $entity_type));
     $this->field->save();
 }
示例#14
0
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('entity_test_rev');
     $entity_type = 'entity_test_rev';
     $this->fieldName = strtolower($this->randomMachineName());
     $this->fieldCardinality = 4;
     $this->fieldStorage = FieldStorageConfig::create(array('field_name' => $this->fieldName, 'entity_type' => $entity_type, 'type' => 'test_field', 'cardinality' => $this->fieldCardinality));
     $this->fieldStorage->save();
     $this->field = FieldConfig::create(['field_storage' => $this->fieldStorage, 'bundle' => $entity_type]);
     $this->field->save();
     /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
     $table_mapping = \Drupal::entityManager()->getStorage($entity_type)->getTableMapping();
     $this->tableMapping = $table_mapping;
     $this->table = $table_mapping->getDedicatedDataTableName($this->fieldStorage);
     $this->revisionTable = $table_mapping->getDedicatedRevisionTableName($this->fieldStorage);
 }
示例#15
0
 /**
  * Creates a text_with_summary field storage and field.
  *
  * @param string $entity_type
  *   Entity type for which the field should be created.
  */
 protected function createField($entity_type)
 {
     // Create a field .
     $this->fieldStorage = entity_create('field_storage_config', array('field_name' => 'summary_field', 'entity_type' => $entity_type, 'type' => 'text_with_summary', 'settings' => array('max_length' => 10)));
     $this->fieldStorage->save();
     $this->field = entity_create('field_config', array('field_storage' => $this->fieldStorage, 'bundle' => $entity_type));
     $this->field->save();
 }
示例#16
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->drupalLogin($this->drupalCreateUser(array('administer views')));
     // Create the text field.
     $this->fieldName = 'field_test_entity_ref_display';
     $this->fieldStorage = FieldStorageConfig::create(['field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'text']);
     $this->fieldStorage->save();
     // Create an instance of the text field on the content type.
     $this->field = FieldConfig::create(['field_storage' => $this->fieldStorage, 'bundle' => 'entity_test']);
     $this->field->save();
     // Create some entities to search. Add a common string to the name and
     // the text field in two entities so we can test that we can search in both.
     for ($i = 0; $i < 5; $i++) {
         EntityTest::create(['bundle' => 'entity_test', 'name' => 'name' . $i, $this->fieldName => 'text'])->save();
         EntityTest::create(['bundle' => 'entity_test', 'name' => 'name', $this->fieldName => 'text' . $i])->save();
     }
 }
示例#17
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Set an explicit site timezone, and disallow per-user timezones.
     $this->config('system.date')->set('timezone.user.configurable', 0)->set('timezone.default', 'Asia/Tokyo')->save();
     $web_user = $this->drupalCreateUser(array('access content', 'view test entity', 'administer entity_test content', 'administer entity_test form display', 'administer content types', 'administer node fields'));
     $this->drupalLogin($web_user);
     // Create a field with settings to validate.
     $field_name = Unicode::strtolower($this->randomMachineName());
     $this->fieldStorage = entity_create('field_storage_config', array('field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'datetime', 'settings' => array('datetime_type' => 'date')));
     $this->fieldStorage->save();
     $this->field = entity_create('field_config', array('field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', 'required' => TRUE));
     $this->field->save();
     entity_get_form_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'default')->setComponent($field_name, array('type' => 'datetime_default'))->save();
     $this->defaultSettings = array('timezone_override' => '');
     $this->displayOptions = array('type' => 'datetime_default', 'label' => 'hidden', 'settings' => array('format_type' => 'medium') + $this->defaultSettings);
     entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')->setComponent($field_name, $this->displayOptions)->save();
 }
示例#18
0
 /**
  * Tests the link title settings of a link field.
  */
 function testLinkTitle()
 {
     $field_name = Unicode::strtolower($this->randomMachineName());
     // Create a field with settings to validate.
     $this->fieldStorage = entity_create('field_storage_config', array('field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'link'));
     $this->fieldStorage->save();
     $this->field = entity_create('field_config', array('field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', 'label' => 'Read more about this entity', 'settings' => array('title' => DRUPAL_OPTIONAL, 'link_type' => LinkItemInterface::LINK_GENERIC)));
     $this->field->save();
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => 'link_default', 'settings' => array('placeholder_url' => 'http://example.com', 'placeholder_title' => 'Enter the text for this link')))->save();
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($field_name, array('type' => 'link', 'label' => 'hidden'))->save();
     // Verify that the link text field works according to the field setting.
     foreach (array(DRUPAL_DISABLED, DRUPAL_REQUIRED, DRUPAL_OPTIONAL) as $title_setting) {
         // Update the link title field setting.
         $this->field->setSetting('title', $title_setting);
         $this->field->save();
         // Display creation form.
         $this->drupalGet('entity_test/add');
         // Assert label is shown.
         $this->assertText('Read more about this entity');
         $this->assertFieldByName("{$field_name}[0][uri]", '', 'URL field found.');
         $this->assertRaw('placeholder="http://example.com"');
         if ($title_setting === DRUPAL_DISABLED) {
             $this->assertNoFieldByName("{$field_name}[0][title]", '', 'Link text field not found.');
             $this->assertNoRaw('placeholder="Enter the text for this link"');
         } else {
             $this->assertRaw('placeholder="Enter the text for this link"');
             $this->assertFieldByName("{$field_name}[0][title]", '', 'Link text field found.');
             if ($title_setting === DRUPAL_REQUIRED) {
                 // Verify that the link text is required, if the URL is non-empty.
                 $edit = array("{$field_name}[0][uri]" => 'http://www.example.com');
                 $this->drupalPostForm(NULL, $edit, t('Save'));
                 $this->assertText(t('@name field is required.', array('@name' => t('Link text'))));
                 // Verify that the link text is not required, if the URL is empty.
                 $edit = array("{$field_name}[0][uri]" => '');
                 $this->drupalPostForm(NULL, $edit, t('Save'));
                 $this->assertNoText(t('@name field is required.', array('@name' => t('Link text'))));
                 // Verify that a URL and link text meets requirements.
                 $this->drupalGet('entity_test/add');
                 $edit = array("{$field_name}[0][uri]" => 'http://www.example.com', "{$field_name}[0][title]" => 'Example');
                 $this->drupalPostForm(NULL, $edit, t('Save'));
                 $this->assertNoText(t('@name field is required.', array('@name' => t('Link text'))));
             }
         }
     }
     // Verify that a link without link text is rendered using the URL as text.
     $value = 'http://www.example.com/';
     $edit = array("{$field_name}[0][uri]" => $value, "{$field_name}[0][title]" => '');
     $this->drupalPostForm(NULL, $edit, t('Save'));
     preg_match('|entity_test/manage/(\\d+)|', $this->url, $match);
     $id = $match[1];
     $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
     $this->renderTestEntity($id);
     $expected_link = \Drupal::l($value, Url::fromUri($value));
     $this->assertRaw($expected_link);
     // Verify that a link with text is rendered using the link text.
     $title = $this->randomMachineName();
     $edit = array("{$field_name}[0][title]" => $title);
     $this->drupalPostForm("entity_test/manage/{$id}", $edit, t('Save'));
     $this->assertText(t('entity_test @id has been updated.', array('@id' => $id)));
     $this->renderTestEntity($id);
     $expected_link = \Drupal::l($title, Url::fromUri($value));
     $this->assertRaw($expected_link);
 }
示例#19
0
 /**
  * Saves field settings.
  */
 protected function saveFieldSettings(array $settings)
 {
     $persisted_settings = $this->field->getSettings();
     // Override allowed values instead of merging.
     foreach (['first', 'second'] as $subfield) {
         if (isset($persisted_settings[$subfield]['allowed_values'], $settings[$subfield]['allowed_values'])) {
             unset($persisted_settings[$subfield]['allowed_values']);
         }
     }
     $this->field->setSettings(NestedArray::mergeDeep($persisted_settings, $settings));
     $this->field->save();
 }