function EntityFormTest::testFormId
Tests the form ID generation.
@covers ::getFormId
      
    
@dataProvider providerTestFormIds
File
- 
              core/tests/ Drupal/ Tests/ Core/ Entity/ EntityFormTest.php, line 54 
Class
- EntityFormTest
- @coversDefaultClass \Drupal\Core\Entity\EntityForm[[api-linebreak]] @group Entity
Namespace
Drupal\Tests\Core\EntityCode
public function testFormId($expected, $definition) : void {
  $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')
    ->willReturn($this->entityType);
  $entity->expects($this->any())
    ->method('bundle')
    ->willReturn($definition['bundle']);
  $this->entityForm
    ->setEntity($entity);
  $this->entityForm
    ->setOperation($definition['operation']);
  $this->assertSame($expected, $this->entityForm
    ->getFormId());
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
