You are here

protected function SelectOtherInstallTestScript::createContentType in CCK Select Other 8

Install configuration for modules.

Parameters

array $values: Optional values to set on the content type.

Return value

string The node type identifier.

Throws

\Drupal\Core\Entity\EntityStorageException

1 call to SelectOtherInstallTestScript::createContentType()
SelectOtherInstallTestScript::setup in tests/src/TestSite/SelectOtherInstallTestScript.php
Run the code to setup the test environment.

File

tests/src/TestSite/SelectOtherInstallTestScript.php, line 78

Class

SelectOtherInstallTestScript
Setup file used for cck_select_other Nightwatch tests.

Namespace

Drupal\Tests\cck_select_other\TestSite

Code

protected function createContentType(array $values = []) {
  if (!isset($values['type'])) {
    $id = $this
      ->randomMachineName();
  }
  else {
    $id = $values['type'];
  }
  $values += [
    'type' => $id,
    'name' => $id,
  ];
  $type = NodeType::create($values);
  $type
    ->save();

  // Create Entity and View displays.
  $formDisplay = EntityFormDisplay::create([
    'targetEntityType' => 'node',
    'bundle' => $id,
    'mode' => 'default',
    'status' => TRUE,
  ]);
  $formDisplay
    ->save();
  $viewDisplay = EntityViewDisplay::create([
    'targetEntityType' => 'node',
    'bundle' => $id,
    'mode' => 'default',
    'status' => TRUE,
  ]);
  $viewDisplay
    ->save();
  return $id;
}