You are here

trait FieldRedirectionTestTrait in Field Redirection 8.2

Testing functions for field_redirection.

Hierarchy

2 files declare their use of FieldRedirectionTestTrait
FormatterConfigurationTest.php in tests/src/Functional/FormatterConfigurationTest.php
FormatterRedirectTest.php in tests/src/Functional/FormatterRedirectTest.php

File

tests/src/Traits/FieldRedirectionTestTrait.php, line 12

Namespace

Drupal\Tests\field_redirection\Traits
View source
trait FieldRedirectionTestTrait {

  /**
   * Sets up a content type with a link field.
   *
   * @return \Drupal\node\Entity\NodeType
   *   Created content type.
   */
  public function setupContentTypeAndField() {
    $contentType = $this
      ->drupalCreateContentType();
    $storage = FieldStorageConfig::create([
      'field_name' => 'url',
      'entity_type' => 'node',
      'type' => 'link',
      'cardinality' => 1,
    ]);
    $storage
      ->save();
    FieldConfig::create([
      'field_storage' => $storage,
      'label' => 'URL',
      'bundle' => $contentType
        ->id(),
      'settings' => [
        'title' => DRUPAL_DISABLED,
        'link_type' => LinkItemInterface::LINK_GENERIC,
      ],
    ])
      ->save();
    return $contentType;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FieldRedirectionTestTrait::setupContentTypeAndField public function Sets up a content type with a link field.