You are here

public function EntityTypeTest::testGetKey in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php \Drupal\Tests\Core\Entity\EntityTypeTest::testGetKey()
  2. 9 core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php \Drupal\Tests\Core\Entity\EntityTypeTest::testGetKey()

Tests the getKey() method.

@dataProvider providerTestGetKeys

File

core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php, line 76

Class

EntityTypeTest
@coversDefaultClass \Drupal\Core\Entity\EntityType @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

public function testGetKey($entity_keys, $expected) {
  $entity_type = $this
    ->setUpEntityType([
    'entity_keys' => $entity_keys,
  ]);
  $this
    ->assertSame($expected['bundle'], $entity_type
    ->getKey('bundle'));
  $this
    ->assertFalse($entity_type
    ->getKey('bananas'));
}