You are here

protected function ViewEntityDependenciesTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php \Drupal\views\Tests\Entity\ViewEntityDependenciesTest::setUp()

Parameters

bool $import_test_views: Should the views specififed on the test class be imported. If you need to setup some additional stuff, like fields, you need to call false and then call createTestViews for your own.

Overrides ViewKernelTestBase::setUp

File

core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php, line 40
Contains \Drupal\views\Tests\Entity\ViewEntityDependenciesTest.

Class

ViewEntityDependenciesTest
Tests the calculation of dependencies for views.

Namespace

Drupal\views\Tests\Entity

Code

protected function setUp() {
  parent::setUp(FALSE);

  // Install the necessary dependencies for node type creation to work.
  $this
    ->installEntitySchema('node');
  $this
    ->installConfig(array(
    'field',
    'node',
  ));
  $comment_type = entity_create('comment_type', array(
    'id' => 'comment',
    'label' => 'Comment settings',
    'description' => 'Comment settings',
    'target_entity_type_id' => 'node',
  ));
  $comment_type
    ->save();
  $content_type = entity_create('node_type', array(
    'type' => $this
      ->randomMachineName(),
    'name' => $this
      ->randomString(),
  ));
  $content_type
    ->save();
  $field_storage = entity_create('field_storage_config', array(
    'field_name' => Unicode::strtolower($this
      ->randomMachineName()),
    'entity_type' => 'node',
    'type' => 'comment',
  ));
  $field_storage
    ->save();
  entity_create('field_config', array(
    'field_storage' => $field_storage,
    'bundle' => $content_type
      ->id(),
    'label' => $this
      ->randomMachineName() . '_label',
    'description' => $this
      ->randomMachineName() . '_description',
    'settings' => array(
      'comment_type' => $comment_type
        ->id(),
    ),
  ))
    ->save();
  entity_create('field_config', array(
    'field_storage' => FieldStorageConfig::loadByName('node', 'body'),
    'bundle' => $content_type
      ->id(),
    'label' => $this
      ->randomMachineName() . '_body',
    'settings' => array(
      'display_summary' => TRUE,
    ),
  ))
    ->save();
  ViewTestData::createTestViews(get_class($this), array(
    'views_test_config',
  ));
}