function EntityTypeTest::testHasKey

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

Tests the hasKey() method.

@dataProvider providerTestGetKeys

File

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

Class

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

Namespace

Drupal\Tests\Core\Entity

Code

public function testHasKey($entity_keys, $expected) {
    $entity_type = $this->setUpEntityType([
        'entity_keys' => $entity_keys,
    ]);
    $this->assertSame(!empty($expected['bundle']), $entity_type->hasKey('bundle'));
    $this->assertSame(!empty($expected['id']), $entity_type->hasKey('id'));
    $this->assertFalse($entity_type->hasKey('bananas'));
}

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