You are here

private function NodeFilterTest::createContentType in Field Formatter Filter 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Kernel/NodeFilterTest.php \Drupal\Tests\field_formatter_filter\Kernel\NodeFilterTest::createContentType()

Set up the content type we use for testing.

This function signiture is compatible with ContentTypeCreationTrait, although it's a total override of it, and ContentTypeCreationTrait is not even used here. The idea is to avoid confusion. That's the *idea* anyway.

Enable the module that provides the content type definition, and other config dependencies it needs.

Our content type definition is imported via config/install/node.type.*.yml not via crud. I thought this was going to be the easy way, but really, the Content Type API is much easier!

Parameters

string $bundle:

1 call to NodeFilterTest::createContentType()
NodeFilterTest::setUp in tests/src/Kernel/NodeFilterTest.php
Derived with reference to from NodeImportCreateTest.

File

tests/src/Kernel/NodeFilterTest.php, line 73

Class

NodeFilterTest
Tests applying the filter formatter to a node.

Namespace

Drupal\Tests\field_formatter_filter\Kernel

Code

private function createContentType(array $values = [
  'type' => 'fff_test_type',
]) {
  $bundle = $values['type'];

  // Not using $this->enableModules() as it does not recurse dependencies.
  $this->container
    ->get('module_installer')
    ->install([
    'fff_content',
  ], TRUE);

  // Verify success before continuing.
  $node_type = NodeType::load($bundle);
  $this
    ->assertTrue($node_type, "The {$bundle} content type was created.");
}