function DefaultTableMappingTest::testGetColumnNames
Tests DefaultTableMapping::getColumnNames().
@legacy-covers ::__construct @legacy-covers ::getColumnNames
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ DefaultTableMappingTest.php, line 213
Class
Namespace
Drupal\Tests\Core\Entity\SqlCode
public function testGetColumnNames() : void {
$definitions['test'] = $this->setUpDefinition('test', []);
$table_mapping = new TestDefaultTableMapping($this->entityType, $definitions);
$expected = [];
$this->assertSame($expected, $table_mapping->getColumnNames('test'));
$definitions['test'] = $this->setUpDefinition('test', [
'value',
]);
$table_mapping = new TestDefaultTableMapping($this->entityType, $definitions);
$expected = [
'value' => 'test',
];
$this->assertSame($expected, $table_mapping->getColumnNames('test'));
$definitions['test'] = $this->setUpDefinition('test', [
'value',
'format',
]);
$table_mapping = new TestDefaultTableMapping($this->entityType, $definitions);
$expected = [
'value' => 'test__value',
'format' => 'test__format',
];
$this->assertSame($expected, $table_mapping->getColumnNames('test'));
$definitions['test'] = $this->setUpDefinition('test', [
'value',
]);
// Set custom storage.
$definitions['test']->expects($this->any())
->method('hasCustomStorage')
->wilLReturn(TRUE);
$table_mapping = new TestDefaultTableMapping($this->entityType, $definitions);
// Should return empty for column names.
$this->assertSame([], $table_mapping->getColumnNames('test'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.