You are here

protected function DataDefinitionFetcherTest::setUp in Typed Data API enhancements 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/DataDefinitionFetcherTest.php, line 51

Class

DataDefinitionFetcherTest
Tests that data fetcher definition fetching functions work correctly.

Namespace

Drupal\Tests\typed_data\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installEntitySchema('node');
  $this->dataFetcher = $this->container
    ->get('typed_data.data_fetcher');
  $this->typedDataManager = $this->container
    ->get('typed_data_manager');
  $entity_type_manager = $this->container
    ->get('entity_type.manager');
  $entity_type_manager
    ->getStorage('node_type')
    ->create([
    'type' => 'page',
  ])
    ->save();

  // Create a multi-value integer field for testing.
  FieldStorageConfig::create([
    'field_name' => 'field_integer',
    'type' => 'integer',
    'entity_type' => 'node',
    'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
  ])
    ->save();
  FieldConfig::create([
    'field_name' => 'field_integer',
    'entity_type' => 'node',
    'bundle' => 'page',
  ])
    ->save();
  $node = $entity_type_manager
    ->getStorage('node')
    ->create([
    'title' => 'test',
    'type' => 'page',
  ]);
  $this->nodeDefinition = $node
    ->getTypedData()
    ->getDataDefinition();
}