function DefaultTableMappingTest::testGetFieldColumnNameInvalid

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php \Drupal\Tests\Core\Entity\Sql\DefaultTableMappingTest::testGetFieldColumnNameInvalid()
  2. 8.9.x core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php \Drupal\Tests\Core\Entity\Sql\DefaultTableMappingTest::testGetFieldColumnNameInvalid()
  3. 11.x core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php \Drupal\Tests\Core\Entity\Sql\DefaultTableMappingTest::testGetFieldColumnNameInvalid()

Tests DefaultTableMapping::getFieldColumnName() with invalid parameters.

@covers ::getFieldColumnName

@dataProvider providerTestGetFieldColumnName

Parameters

bool $base_field: Flag indicating whether the field should be treated as a base or bundle field.

string[] $columns: An array of available field column names.

string $column: The name of the column to be processed.

File

core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php, line 304

Class

DefaultTableMappingTest
@coversDefaultClass \Drupal\Core\Entity\Sql\DefaultTableMapping @group Entity

Namespace

Drupal\Tests\Core\Entity\Sql

Code

public function testGetFieldColumnNameInvalid($base_field, $columns, $column) : void {
    $definitions['test'] = $this->setUpDefinition('test', $columns, $base_field);
    // Mark field storage definition as custom storage.
    $definitions['test']->expects($this->any())
        ->method('hasCustomStorage')
        ->willReturn(TRUE);
    $table_mapping = new TestDefaultTableMapping($this->entityType, $definitions);
    $this->expectException(SqlContentEntityStorageException::class);
    $this->expectExceptionMessage("Column information not available for the 'test' field.");
    $table_mapping->getFieldColumnName($definitions['test'], $column);
}

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