function EntityFormTest::setUpStorage

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php \Drupal\Tests\Core\Entity\EntityFormTest::setUpStorage()
  2. 10 core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php \Drupal\Tests\Core\Entity\EntityFormTest::setUpStorage()
  3. 11.x core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php \Drupal\Tests\Core\Entity\EntityFormTest::setUpStorage()

Sets up the storage accessed via the entity type manager in the form.

Return value

\Prophecy\Prophecy\ObjectProphecy The storage prophecy.

2 calls to EntityFormTest::setUpStorage()
EntityFormTest::testGetEntityFromRouteMatchAddEntity in core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php
Tests EntityForm::getEntityFromRouteMatch() with a config entity bundle.
EntityFormTest::testGetEntityFromRouteMatchAddStatic in core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php
Tests EntityForm::getEntityFromRouteMatch() with a static bundle.

File

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

Class

EntityFormTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Entity%21EntityForm.php/class/EntityForm/8.9.x" title="Base class for entity forms." class="local">\Drupal\Core\Entity\EntityForm</a> @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

protected function setUpStorage() {
    $storage = $this->prophesize(EntityStorageInterface::class);
    $entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class);
    $entity_type_manager->getDefinition($this->entityType
        ->id())
        ->willReturn($this->entityType);
    $entity_type_manager->getStorage($this->entityType
        ->id())
        ->willReturn($storage->reveal());
    $this->entityForm
        ->setEntityTypeManager($entity_type_manager->reveal());
    return $storage;
}

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