You are here

ColorFieldFunctionalTestBase.php in Color Field 8.2

File

tests/src/Functional/ColorFieldFunctionalTestBase.php
View source
<?php

namespace Drupal\Tests\color_field\Functional;

use Drupal\field\Entity\FieldConfig;
use Drupal\Tests\BrowserTestBase;
use Drupal\field\Entity\FieldStorageConfig;

/**
 * Provide basic setup for all color field functional tests.
 *
 * @group color_field
 */
abstract class ColorFieldFunctionalTestBase extends BrowserTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = [
    'field',
    'node',
    'color_field',
  ];

  /**
   * The Entity View Display for the article node type.
   *
   * @var \Drupal\Core\Entity\Entity\EntityViewDisplay
   */
  protected $display;

  /**
   * The Entity Form Display for the article node type.
   *
   * @var \Drupal\Core\Entity\Entity\EntityFormDisplay
   */
  protected $form;

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this
      ->drupalCreateContentType([
      'type' => 'article',
    ]);
    $user = $this
      ->drupalCreateUser([
      'create article content',
      'edit own article content',
    ]);
    $this
      ->drupalLogin($user);
    $entityTypeManager = $this->container
      ->get('entity_type.manager');
    FieldStorageConfig::create([
      'field_name' => 'field_color',
      'entity_type' => 'node',
      'type' => 'color_field_type',
    ])
      ->save();
    FieldConfig::create([
      'field_name' => 'field_color',
      'label' => 'Freeform Color',
      'description' => 'Color field description',
      'entity_type' => 'node',
      'bundle' => 'article',
    ])
      ->save();
    $this->form = $entityTypeManager
      ->getStorage('entity_form_display')
      ->load('node.article.default');
    $this->display = $entityTypeManager
      ->getStorage('entity_view_display')
      ->load('node.article.default');
  }

}

Classes

Namesort descending Description
ColorFieldFunctionalTestBase Provide basic setup for all color field functional tests.