function DefaultTableMappingTest::testGetTableNames

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

Tests DefaultTableMapping::getTableNames().

@covers ::getTableNames

File

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

Class

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

Namespace

Drupal\Tests\Core\Entity\Sql

Code

public function testGetTableNames() {
    // The storage definitions are only used in getColumnNames() so we do not
    // need to provide any here.
    $table_mapping = new TestDefaultTableMapping($this->entityType, []);
    $this->assertSame([], $table_mapping->getTableNames());
    $table_mapping->setFieldNames('foo', []);
    $this->assertSame([
        'foo',
    ], $table_mapping->getTableNames());
    $table_mapping->setFieldNames('bar', []);
    $this->assertSame([
        'foo',
        'bar',
    ], $table_mapping->getTableNames());
    $table_mapping->setExtraColumns('baz', []);
    $this->assertSame([
        'foo',
        'bar',
        'baz',
    ], $table_mapping->getTableNames());
    // Test that table names are not duplicated.
    $table_mapping->setExtraColumns('foo', []);
    $this->assertSame([
        'foo',
        'bar',
        'baz',
    ], $table_mapping->getTableNames());
}

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