You are here

public function EntityFormBuilderTest::testGetForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php \Drupal\Tests\Core\Entity\EntityFormBuilderTest::testGetForm()

Tests the getForm() method.

@covers ::getForm

File

core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php, line 56
Contains \Drupal\Tests\Core\Entity\EntityFormBuilderTest.

Class

EntityFormBuilderTest
@coversDefaultClass \Drupal\Core\Entity\EntityFormBuilder @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

public function testGetForm() {
  $form_controller = $this
    ->getMock('Drupal\\Core\\Entity\\EntityFormInterface');
  $form_controller
    ->expects($this
    ->any())
    ->method('getFormId')
    ->will($this
    ->returnValue('the_form_id'));
  $this->entityManager
    ->expects($this
    ->any())
    ->method('getFormObject')
    ->with('the_entity_type', 'default')
    ->will($this
    ->returnValue($form_controller));
  $this->formBuilder
    ->expects($this
    ->once())
    ->method('buildForm')
    ->with($form_controller, $this
    ->isInstanceOf('Drupal\\Core\\Form\\FormStateInterface'))
    ->will($this
    ->returnValue('the form contents'));
  $entity = $this
    ->getMock('Drupal\\Core\\Entity\\EntityInterface');
  $entity
    ->expects($this
    ->once())
    ->method('getEntityTypeId')
    ->will($this
    ->returnValue('the_entity_type'));
  $this
    ->assertSame('the form contents', $this->entityFormBuilder
    ->getForm($entity));
}