ExtraFieldBrowserTestBase.php in Extra Field 8.2
File
tests/src/Functional/ExtraFieldBrowserTestBase.php
View source
<?php
namespace Drupal\Tests\extra_field\Functional;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Tests\BrowserTestBase;
abstract class ExtraFieldBrowserTestBase extends BrowserTestBase {
protected $defaultTheme = 'stark';
protected $contentTypeName;
public function setupContentEntityForm($contentType) {
$this->contentTypeName = $contentType;
$this
->createContentType([
'type' => $contentType,
]);
EntityFormDisplay::create([
'targetEntityType' => 'node',
'bundle' => $contentType,
'mode' => 'default',
]);
}
public function setupContentEntityDisplay($contentType) {
$this->contentTypeName = $contentType;
$this
->createContentType([
'type' => $contentType,
]);
EntityViewDisplay::create([
'targetEntityType' => 'node',
'bundle' => $contentType,
'mode' => 'default',
'status' => TRUE,
]);
}
public function createContent($contentType) {
$this
->createContentType([
'type' => $contentType,
]);
$node = \Drupal::entityTypeManager()
->getStorage('node')
->create([
'type' => $contentType,
'title' => $this
->randomMachineName(),
]);
$node
->save();
return $node;
}
}