function EntityStorageBaseTest::generateEntityInterface

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/EntityStorageBaseTest.php \Drupal\Tests\Core\Entity\EntityStorageBaseTest::generateEntityInterface()
  2. 10 core/tests/Drupal/Tests/Core/Entity/EntityStorageBaseTest.php \Drupal\Tests\Core\Entity\EntityStorageBaseTest::generateEntityInterface()

Generate a mocked entity object.

Parameters

string $id: ID value for this entity.

Return value

\Drupal\Core\Entity\EntityInterface|\PHPUnit\Framework\MockObject\MockObject The mocked entity.

1 call to EntityStorageBaseTest::generateEntityInterface()
EntityStorageBaseTest::testLoad in core/tests/Drupal/Tests/Core/Entity/EntityStorageBaseTest.php
@covers ::load

File

core/tests/Drupal/Tests/Core/Entity/EntityStorageBaseTest.php, line 26

Class

EntityStorageBaseTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Entity%21EntityStorageBase.php/class/EntityStorageBase/11.x" title="A base entity storage class." class="local">\Drupal\Core\Entity\EntityStorageBase</a> @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

public function generateEntityInterface(string $id) : EntityInterface&MockObject {
    $mock_entity = $this->createMock(EntityInterface::class);
    $mock_entity->expects($this->any())
        ->method('id')
        ->willReturn($id);
    return $mock_entity;
}

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