function DefaultTableMappingTest::testGetAllColumns
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php \Drupal\Tests\Core\Entity\Sql\DefaultTableMappingTest::testGetAllColumns()
- 8.9.x core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php \Drupal\Tests\Core\Entity\Sql\DefaultTableMappingTest::testGetAllColumns()
- 11.x core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php \Drupal\Tests\Core\Entity\Sql\DefaultTableMappingTest::testGetAllColumns()
Tests DefaultTableMapping::getAllColumns().
@covers ::__construct @covers ::getAllColumns @covers ::getFieldNames @covers ::getColumnNames @covers ::setFieldNames @covers ::getExtraColumns @covers ::setExtraColumns
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ DefaultTableMappingTest.php, line 73
Class
- DefaultTableMappingTest
- @coversDefaultClass \Drupal\Core\Entity\Sql\DefaultTableMapping @group Entity
Namespace
Drupal\Tests\Core\Entity\SqlCode
public function testGetAllColumns() : void {
// Set up single-column and multi-column definitions.
$definitions['id'] = $this->setUpDefinition('id', [
'value',
]);
$definitions['name'] = $this->setUpDefinition('name', [
'value',
]);
$definitions['type'] = $this->setUpDefinition('type', [
'value',
]);
$definitions['description'] = $this->setUpDefinition('description', [
'value',
'format',
]);
$definitions['owner'] = $this->setUpDefinition('owner', [
'target_id',
'target_revision_id',
]);
$table_mapping = new TestDefaultTableMapping($this->entityType, $definitions);
$expected = [];
$this->assertSame($expected, $table_mapping->getAllColumns('test'));
// Test adding field columns.
$table_mapping->setFieldNames('test', [
'id',
]);
$expected = [
'id',
];
$this->assertSame($expected, $table_mapping->getAllColumns('test'));
$table_mapping->setFieldNames('test', [
'id',
'name',
]);
$expected = [
'id',
'name',
];
$this->assertSame($expected, $table_mapping->getAllColumns('test'));
$table_mapping->setFieldNames('test', [
'id',
'name',
'type',
]);
$expected = [
'id',
'name',
'type',
];
$this->assertSame($expected, $table_mapping->getAllColumns('test'));
$table_mapping->setFieldNames('test', [
'id',
'name',
'type',
'description',
]);
$expected = [
'id',
'name',
'type',
'description__value',
'description__format',
];
$this->assertSame($expected, $table_mapping->getAllColumns('test'));
$table_mapping->setFieldNames('test', [
'id',
'name',
'type',
'description',
'owner',
]);
$expected = [
'id',
'name',
'type',
'description__value',
'description__format',
'owner__target_id',
'owner__target_revision_id',
];
$this->assertSame($expected, $table_mapping->getAllColumns('test'));
// Test adding extra columns.
$table_mapping->setFieldNames('test', []);
$table_mapping->setExtraColumns('test', [
'default_langcode',
]);
$expected = [
'default_langcode',
];
$this->assertSame($expected, $table_mapping->getAllColumns('test'));
$table_mapping->setExtraColumns('test', [
'default_langcode',
'default_revision',
]);
$expected = [
'default_langcode',
'default_revision',
];
$this->assertSame($expected, $table_mapping->getAllColumns('test'));
// Test adding both field and extra columns.
$table_mapping->setFieldNames('test', [
'id',
'name',
'type',
'description',
'owner',
]);
$table_mapping->setExtraColumns('test', [
'default_langcode',
'default_revision',
]);
$expected = [
'id',
'name',
'type',
'description__value',
'description__format',
'owner__target_id',
'owner__target_revision_id',
'default_langcode',
'default_revision',
];
$this->assertSame($expected, $table_mapping->getAllColumns('test'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.