function KeyValueEntityStorageTest::getMockEntity

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::getMockEntity()
  2. 8.9.x core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::getMockEntity()
  3. 11.x core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::getMockEntity()

Creates an entity with specific methods mocked.

Parameters

string $class: (optional) The concrete entity class to mock. Defaults to 'Drupal\Core\Entity\EntityBase'.

array $arguments: (optional) Arguments to pass to the constructor. An empty set of values and an entity type ID will be provided.

array $methods: (optional) The methods to mock.

Return value

\Drupal\Core\Entity\EntityInterface|\PHPUnit\Framework\MockObject\MockObject

11 calls to KeyValueEntityStorageTest::getMockEntity()
KeyValueEntityStorageTest::testCreate in core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@covers ::create[[api-linebreak]] @covers ::doCreate[[api-linebreak]]
KeyValueEntityStorageTest::testCreateWithoutUuidKey in core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@covers ::create[[api-linebreak]] @covers ::doCreate[[api-linebreak]]
KeyValueEntityStorageTest::testCreateWithPredefinedUuid in core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@covers ::create[[api-linebreak]] @covers ::doCreate[[api-linebreak]]
KeyValueEntityStorageTest::testDelete in core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@covers ::delete[[api-linebreak]] @covers ::doDelete[[api-linebreak]]
KeyValueEntityStorageTest::testLoad in core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@covers ::load[[api-linebreak]] @covers ::postLoad[[api-linebreak]]

... See full list

File

core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php, line 639

Class

KeyValueEntityStorageTest
@coversDefaultClass \Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage[[api-linebreak]] @group Entity

Namespace

Drupal\Tests\Core\Entity\KeyValueStore

Code

public function getMockEntity($class = EntityBaseTest::class, array $arguments = [], $methods = []) {
  // Ensure the entity is passed at least an array of values and an entity
  // type ID
  if (!isset($arguments[0])) {
    $arguments[0] = [];
  }
  if (!isset($arguments[1])) {
    $arguments[1] = 'test_entity_type';
  }
  return $this->getMockForAbstractClass($class, $arguments, '', TRUE, TRUE, TRUE, $methods);
}

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