function DefaultTableMappingTest::testGetExtraColumns
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php \Drupal\Tests\Core\Entity\Sql\DefaultTableMappingTest::testGetExtraColumns()
- 8.9.x core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php \Drupal\Tests\Core\Entity\Sql\DefaultTableMappingTest::testGetExtraColumns()
- 11.x core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php \Drupal\Tests\Core\Entity\Sql\DefaultTableMappingTest::testGetExtraColumns()
Tests DefaultTableMapping::getExtraColumns().
@covers ::getExtraColumns @covers ::setExtraColumns
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ DefaultTableMappingTest.php, line 241
Class
- DefaultTableMappingTest
- @coversDefaultClass \Drupal\Core\Entity\Sql\DefaultTableMapping @group Entity
Namespace
Drupal\Tests\Core\Entity\SqlCode
public function testGetExtraColumns() : void {
// The storage definitions are only used in getColumnNames() so we do not
// need to provide any here.
$table_mapping = new TestDefaultTableMapping($this->entityType, []);
// Test that requesting the list of field names for a table for which no
// fields have been added does not fail.
$this->assertSame([], $table_mapping->getExtraColumns('foo'));
$return = $table_mapping->setExtraColumns('foo', [
'id',
'name',
'type',
]);
$this->assertSame($table_mapping, $return);
$expected = [
'id',
'name',
'type',
];
$this->assertSame($expected, $table_mapping->getExtraColumns('foo'));
$this->assertSame([], $table_mapping->getExtraColumns('bar'));
$return = $table_mapping->setExtraColumns('bar', [
'description',
'owner',
]);
$this->assertSame($table_mapping, $return);
$expected = [
'description',
'owner',
];
$this->assertSame($expected, $table_mapping->getExtraColumns('bar'));
// Test that the previously added field names are unaffected.
$expected = [
'id',
'name',
'type',
];
$this->assertSame($expected, $table_mapping->getExtraColumns('foo'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.