You are here

protected function SqlContentEntityStorageTest::mockFieldDefinitions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::mockFieldDefinitions()

Returns a set of mock field definitions for the given names.

Parameters

array $field_names: An array of field names.

array $methods: (optional) An associative array of mock method return values keyed by method name.

Return value

\Drupal\Tests\Core\Field\TestBaseFieldDefinitionInterface[]|\PHPUnit_Framework_MockObject_MockObject[] An array of mock base field definitions.

6 calls to SqlContentEntityStorageTest::mockFieldDefinitions()
SqlContentEntityStorageTest::testCleanIds in core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php
Tests entity ID sanitization.
SqlContentEntityStorageTest::testGetTableMappingRevisionableTranslatableWithFields in core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php
Tests getTableMapping() with a complex entity type with fields.
SqlContentEntityStorageTest::testGetTableMappingRevisionableWithFields in core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php
Tests getTableMapping() with a revisionable entity type with fields.
SqlContentEntityStorageTest::testGetTableMappingSimpleWithFields in core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php
Tests getTableMapping() with a simple entity type with some base fields.
SqlContentEntityStorageTest::testGetTableMappingTranslatableWithFields in core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php
Tests getTableMapping() with a translatable entity type with fields.

... See full list

File

core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php, line 1005
Contains \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest.

Class

SqlContentEntityStorageTest
@coversDefaultClass \Drupal\Core\Entity\Sql\SqlContentEntityStorage @group Entity

Namespace

Drupal\Tests\Core\Entity\Sql

Code

protected function mockFieldDefinitions(array $field_names, $methods = array()) {
  $field_definitions = array();
  $definition = $this
    ->getMock('Drupal\\Tests\\Core\\Field\\TestBaseFieldDefinitionInterface');

  // Assign common method return values.
  $methods += array(
    'isBaseField' => TRUE,
  );
  foreach ($methods as $method => $result) {
    $definition
      ->expects($this
      ->any())
      ->method($method)
      ->will($this
      ->returnValue($result));
  }

  // Assign field names to mock definitions.
  foreach ($field_names as $field_name) {
    $field_definitions[$field_name] = clone $definition;
    $field_definitions[$field_name]
      ->expects($this
      ->any())
      ->method('getName')
      ->will($this
      ->returnValue($field_name));
  }
  return $field_definitions;
}