function SqlContentEntityStorageTest::mockFieldDefinitions

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::mockFieldDefinitions()
  2. 8.9.x core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest::mockFieldDefinitions()
  3. 11.x 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.

8 calls to SqlContentEntityStorageTest::mockFieldDefinitions()
SqlContentEntityStorageTest::testCleanIds in core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php
Tests entity ID sanitization.
SqlContentEntityStorageTest::testGetTableMappingRevisionableTranslatable in core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php
Tests getTableMapping() with a revisionable, translatable entity type.
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::testGetTableMappingSimpleWithDedicatedStorageFields in core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php
Tests getTableMapping() with a base field that requires a dedicated table.

... See full list

File

core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php, line 1129

Class

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

Namespace

Drupal\Tests\Core\Entity\Sql

Code

protected function mockFieldDefinitions(array $field_names, $methods = []) {
    $field_definitions = [];
    $definition = $this->createMock('Drupal\\Tests\\Core\\Field\\TestBaseFieldDefinitionInterface');
    // Assign common method return values.
    $methods += [
        'isBaseField' => TRUE,
    ];
    foreach ($methods as $method => $result) {
        $definition->expects($this->any())
            ->method($method)
            ->willReturn($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')
            ->willReturn($field_name);
    }
    return $field_definitions;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.