function EntityStorageBaseTest::generateEntityInterface

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/EntityStorageBaseTest.php \Drupal\Tests\Core\Entity\EntityStorageBaseTest::generateEntityInterface()
  2. 11.x 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 \Drupal\Core\Entity\EntityStorageBase @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.