You are here

protected function EntityViewsDataTest::setupFieldStorageDefinition in Zircon Profile 8

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

Helper method to mock all store definitions.

3 calls to EntityViewsDataTest::setupFieldStorageDefinition()
EntityViewsDataTest::testBaseTableFields in core/modules/views/tests/src/Unit/EntityViewsDataTest.php
Tests fields on the base table.
EntityViewsDataTest::testDataTableFields in core/modules/views/tests/src/Unit/EntityViewsDataTest.php
Tests fields on the data table.
EntityViewsDataTest::testRevisionTableFields in core/modules/views/tests/src/Unit/EntityViewsDataTest.php
Tests fields on the revision table.

File

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

Class

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

Namespace

Drupal\Tests\views\Unit

Code

protected function setupFieldStorageDefinition() {
  $id_field_storage_definition = $this
    ->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface');
  $id_field_storage_definition
    ->expects($this
    ->any())
    ->method('getSchema')
    ->willReturn(IntegerItem::schema($id_field_storage_definition));
  $uuid_field_storage_definition = $this
    ->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface');
  $uuid_field_storage_definition
    ->expects($this
    ->any())
    ->method('getSchema')
    ->willReturn(UuidItem::schema($uuid_field_storage_definition));
  $type_field_storage_definition = $this
    ->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface');
  $type_field_storage_definition
    ->expects($this
    ->any())
    ->method('getSchema')
    ->willReturn(StringItem::schema($type_field_storage_definition));
  $langcode_field_storage_definition = $this
    ->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface');
  $langcode_field_storage_definition
    ->expects($this
    ->any())
    ->method('getSchema')
    ->willReturn(LanguageItem::schema($langcode_field_storage_definition));
  $name_field_storage_definition = $this
    ->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface');
  $name_field_storage_definition
    ->expects($this
    ->any())
    ->method('getSchema')
    ->willReturn(StringItem::schema($name_field_storage_definition));
  $description_field_storage_definition = $this
    ->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface');
  $description_field_storage_definition
    ->expects($this
    ->any())
    ->method('getSchema')
    ->willReturn(TextLongItem::schema($description_field_storage_definition));
  $homepage_field_storage_definition = $this
    ->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface');
  $homepage_field_storage_definition
    ->expects($this
    ->any())
    ->method('getSchema')
    ->willReturn(UriItem::schema($homepage_field_storage_definition));

  // Setup the user_id entity reference field.
  $this->entityManager
    ->expects($this
    ->any())
    ->method('getDefinition')
    ->willReturnMap([
    [
      'user',
      TRUE,
      static::userEntityInfo(),
    ],
  ]);
  $user_id_field_storage_definition = $this
    ->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface');
  $user_id_field_storage_definition
    ->expects($this
    ->any())
    ->method('getSetting')
    ->with('target_type')
    ->willReturn('user');
  $user_id_field_storage_definition
    ->expects($this
    ->any())
    ->method('getSettings')
    ->willReturn([
    'target_type' => 'user',
  ]);
  $user_id_field_storage_definition
    ->expects($this
    ->any())
    ->method('getSchema')
    ->willReturn(EntityReferenceItem::schema($user_id_field_storage_definition));
  $revision_id_field_storage_definition = $this
    ->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface');
  $revision_id_field_storage_definition
    ->expects($this
    ->any())
    ->method('getSchema')
    ->willReturn(IntegerItem::schema($revision_id_field_storage_definition));
  $this->entityManager
    ->expects($this
    ->any())
    ->method('getFieldStorageDefinitions')
    ->willReturn([
    'id' => $id_field_storage_definition,
    'uuid' => $uuid_field_storage_definition,
    'type' => $type_field_storage_definition,
    'langcode' => $langcode_field_storage_definition,
    'name' => $name_field_storage_definition,
    'description' => $description_field_storage_definition,
    'homepage' => $homepage_field_storage_definition,
    'user_id' => $user_id_field_storage_definition,
    'revision_id' => $revision_id_field_storage_definition,
  ]);
}