function DefaultTableMappingTest::testGetColumnNames
Tests DefaultTableMapping::getColumnNames().
@covers ::__construct
      
    
@covers ::getColumnNames
      
    
File
- 
              core/tests/ Drupal/ Tests/ Core/ Entity/ Sql/ DefaultTableMappingTest.php, line 207 
Class
- DefaultTableMappingTest
- @coversDefaultClass \Drupal\Core\Entity\Sql\DefaultTableMapping[[api-linebreak]] @group Entity
Namespace
Drupal\Tests\Core\Entity\SqlCode
public function testGetColumnNames() {
  $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.
