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;
abstract class ColorFieldFunctionalTestBase extends BrowserTestBase {
public static $modules = [
'field',
'node',
'color_field',
];
protected $display;
protected $form;
protected $defaultTheme = 'stark';
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');
}
}