function EntityTypeManagerTest::testGetFormObject
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php \Drupal\Tests\Core\Entity\EntityTypeManagerTest::testGetFormObject()
- 10 core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php \Drupal\Tests\Core\Entity\EntityTypeManagerTest::testGetFormObject()
- 11.x core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php \Drupal\Tests\Core\Entity\EntityTypeManagerTest::testGetFormObject()
Tests the getFormObject() method.
@covers ::getFormObject
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityTypeManagerTest.php, line 233
Class
- EntityTypeManagerTest
- @coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Entity%21EntityTypeManager.php/class/EntityTypeManager/8.9.x" title="Manages entity type plugin definitions." class="local">\Drupal\Core\Entity\EntityTypeManager</a> @group Entity
Namespace
Drupal\Tests\Core\EntityCode
public function testGetFormObject() {
$apple = $this->prophesize(EntityTypeInterface::class);
$apple->getFormClass('default')
->willReturn(TestEntityForm::class);
$banana = $this->prophesize(EntityTypeInterface::class);
$banana->getFormClass('default')
->willReturn(TestEntityFormInjected::class);
$this->setUpEntityTypeDefinitions([
'apple' => $apple,
'banana' => $banana,
]);
$apple_form = $this->entityTypeManager
->getFormObject('apple', 'default');
$this->assertInstanceOf(TestEntityForm::class, $apple_form);
$this->assertAttributeInstanceOf(ModuleHandlerInterface::class, 'moduleHandler', $apple_form);
$this->assertAttributeInstanceOf(TranslationInterface::class, 'stringTranslation', $apple_form);
$banana_form = $this->entityTypeManager
->getFormObject('banana', 'default');
$this->assertInstanceOf(TestEntityFormInjected::class, $banana_form);
$this->assertAttributeEquals('yellow', 'color', $banana_form);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.