You are here

public function EntityFormTest::testFormId in Drupal 10

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

Tests the form ID generation.

@covers ::getFormId

@dataProvider providerTestFormIds

File

core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php, line 52

Class

EntityFormTest
@coversDefaultClass \Drupal\Core\Entity\EntityForm @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

public function testFormId($expected, $definition) {
  $this->entityType
    ->set('entity_keys', [
    'bundle' => $definition['bundle'],
  ]);
  $entity = $this
    ->getMockForAbstractClass('Drupal\\Core\\Entity\\EntityBase', [
    [],
    $definition['entity_type'],
  ], '', TRUE, TRUE, TRUE, [
    'getEntityType',
    'bundle',
  ]);
  $entity
    ->expects($this
    ->any())
    ->method('getEntityType')
    ->will($this
    ->returnValue($this->entityType));
  $entity
    ->expects($this
    ->any())
    ->method('bundle')
    ->will($this
    ->returnValue($definition['bundle']));
  $this->entityForm
    ->setEntity($entity);
  $this->entityForm
    ->setOperation($definition['operation']);
  $this
    ->assertSame($expected, $this->entityForm
    ->getFormId());
}