assertFieldSelectOptions example

// Create entity reference field with node as a target.     $node_field_name = $this->createEntityReferenceField('node', [$this->type]);

    // Create entity reference field with date format as a target.     $date_format_field_name = $this->createEntityReferenceField('date_format');

    // Display all newly created Entity Reference configuration.     $this->drupalGet('admin/structure/types/manage/' . $this->type . '/display');

    // Check for Taxonomy Term select box values.     // Test if Taxonomy Term Entity Reference Field has the correct formatters.     $this->assertFieldSelectOptions('fields[field_' . $taxonomy_term_field_name . '][type]', [
      'entity_reference_label',
      'entity_reference_entity_id',
      'entity_reference_rss_category',
      'entity_reference_entity_view',
    ]);

    // Test if User Reference Field has the correct formatters.     // Author should be available for this field.     // RSS Category should not be available for this field.     $this->assertFieldSelectOptions('fields[field_' . $user_field_name . '][type]', [
      'author',
      
$page->findField('new_storage_type')->setValue('entity_reference');
    $assert_session->waitForField('label')->setValue('Test');
    $machine_name = $assert_session->waitForElement('xpath', '//*[@id="edit-label-machine-name-suffix"]/span[contains(text(), "field_test")]');
    $this->assertNotEmpty($machine_name);
    $page->pressButton('Save and continue');

    // Node should be selected by default.     $this->assertSession()->fieldValueEquals('settings[target_type]', 'node');

    // Check that all entity types can be referenced.     $this->assertFieldSelectOptions('settings[target_type]', array_keys(\Drupal::entityTypeManager()->getDefinitions()));

    // Second step: 'Field settings' form.     $this->submitForm([], 'Save field settings');

    // The base handler should be selected by default.     $this->assertSession()->fieldValueEquals('settings[handler]', 'default:node');

    // The base handler settings should be displayed.     $entity_type_id = 'node';
    // Check that the type label is correctly displayed.     $assert_session->pageTextContains('Content type');
    
$field_test_drag_handle = $page->find('css', '#field-test .tabledrag-handle');
    $field_test_settings = $page->find('css', 'input[name="field_test_settings_edit"]');
    $weight_toggle = $page->find('css', '.tabledrag-toggle-weight');

    // Assert the format type field is visible and contains the expected     // formatter.     $this->assertTrue($field_test_format_type->isVisible());
    $this->assertEquals($format$field_test_format_type->getValue());
    $assert_session->responseContains("$setting_name: $setting_value");

    // Validate the selectbox.     $this->assertFieldSelectOptions($field_test_format_type[
      'field_no_settings',
      'field_empty_test',
      'field_empty_setting',
      'field_test_default',
      'field_test_multiple',
      'field_test_with_prepare_view',
      'field_test_applicable',
    ]);

    // Ensure that fields can be hidden directly by dragging the element.     $target = $page->find('css', '.region-hidden-message');
    
Home | Imprint | This part of the site doesn't use cookies.