fieldUIAddNewFieldJS example

$this->entityTypeManager = $this->container->get('entity_type.manager');
  }

  /** * Tests formatter settings. */
  public function testFormatterUI() {
    $manage_fields = 'admin/structure/types/manage/' . $this->type;
    $manage_display = $manage_fields . '/display';

    // Create a field, and a node with some data for the field.     $this->fieldUIAddNewFieldJS($manage_fields, 'test', 'Test field');

    $display_id = 'node.' . $this->type . '.default';
    $displayStorage = $this->entityTypeManager->getStorage('entity_view_display');

    // Get the display options (formatter and settings) that were automatically     // assigned for the 'default' display.     /** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */
    $display = $displayStorage->loadUnchanged($display_id);
    $display_options = $display->getComponent('field_test');
    $format = $display_options['type'];
    $default_settings = \Drupal::service('plugin.manager.field.formatter')->getDefaultSettings($format);
    
/** * Tests re-using an existing field and the visibility of the re-use button. */
  public function testReuseExistingField() {
    $path = 'admin/structure/types/manage/article';
    $path2 = 'admin/structure/types/manage/page';
    $this->drupalGet($path2 . '/fields');
    // The button should not be visible without any re-usable fields.     $this->assertSession()->linkNotExists('Re-use an existing field');
    $field_label = 'Test field';
    // Create a field, and a node with some data for the field.     $this->fieldUIAddNewFieldJS($path, 'test', $field_label);
    // Add an existing field.     $this->fieldUIAddExistingFieldJS($path2, 'field_test', $field_label);
    // Confirm the button is no longer visible after re-using the field.     $this->assertSession()->linkNotExists('Re-use an existing field');
  }

  /** * Tests filter results in the re-use form. */
  public function testFilterInReuseForm() {
    $session = $this->getSession();
    
Home | Imprint | This part of the site doesn't use cookies.