You are here

protected function EntityViewsDataTest::setUp in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Unit/EntityViewsDataTest.php \Drupal\Tests\views\Unit\EntityViewsDataTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/views/tests/src/Unit/EntityViewsDataTest.php, line 80
Contains \Drupal\Tests\views\Unit\EntityViewsDataTest.

Class

EntityViewsDataTest
@coversDefaultClass \Drupal\views\EntityViewsData @group Views

Namespace

Drupal\Tests\views\Unit

Code

protected function setUp() {
  $this->entityStorage = $this
    ->getMockBuilder('Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorage')
    ->disableOriginalConstructor()
    ->getMock();
  $this->entityManager = $this
    ->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
  $typed_data_manager = $this
    ->getMockBuilder('Drupal\\Core\\TypedData\\TypedDataManager')
    ->disableOriginalConstructor()
    ->getMock();
  $typed_data_manager
    ->expects($this
    ->any())
    ->method('createDataDefinition')
    ->willReturn($this
    ->getMock('Drupal\\Core\\TypedData\\DataDefinitionInterface'));
  $this->baseEntityType = new TestEntityType([
    'base_table' => 'entity_test',
    'id' => 'entity_test',
    'label' => 'Entity test',
    'entity_keys' => [
      'id' => 'id',
      'langcode' => 'langcode',
      'bundle' => 'type',
      'revision' => 'revision_id',
    ],
    'provider' => 'entity_test',
    'list_cache_contexts' => [
      'entity_test_list_cache_context',
    ],
  ]);
  $this->translationManager = $this
    ->getStringTranslationStub();
  $this->moduleHandler = $this
    ->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
  $this->viewsData = new TestEntityViewsData($this->baseEntityType, $this->entityStorage, $this->entityManager, $this->moduleHandler, $this->translationManager);
  $field_type_manager = $this
    ->getMockBuilder('Drupal\\Core\\Field\\FieldTypePluginManager')
    ->disableOriginalConstructor()
    ->getMock();
  $field_type_manager
    ->expects($this
    ->any())
    ->method('getDefaultStorageSettings')
    ->willReturn([]);
  $field_type_manager
    ->expects($this
    ->any())
    ->method('getDefaultFieldSettings')
    ->willReturn([]);
  $container = new ContainerBuilder();
  $container
    ->set('plugin.manager.field.field_type', $field_type_manager);
  $container
    ->set('entity.manager', $this->entityManager);
  $container
    ->set('typed_data_manager', $typed_data_manager);
  \Drupal::setContainer($container);
}