function KeyValueEntityStorageTest::getMockEntity
Same name and namespace in other branches
- 10 core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::getMockEntity()
- 9 core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::getMockEntity()
- 8.9.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 a stub of \Drupal\Core\Entity\EntityBase defined for test purposes.
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 A mock entity instance with the specified methods mocked.
12 calls to KeyValueEntityStorageTest::getMockEntity()
- KeyValueEntityStorageTest::testCreate in core/
tests/ Drupal/ Tests/ Core/ Entity/ KeyValueStore/ KeyValueEntityStorageTest.php - Tests create.
- KeyValueEntityStorageTest::testCreateWithoutUuidKey in core/
tests/ Drupal/ Tests/ Core/ Entity/ KeyValueStore/ KeyValueEntityStorageTest.php - Tests create without uuid key.
- KeyValueEntityStorageTest::testCreateWithPredefinedUuid in core/
tests/ Drupal/ Tests/ Core/ Entity/ KeyValueStore/ KeyValueEntityStorageTest.php - Tests create with predefined uuid.
- KeyValueEntityStorageTest::testDelete in core/
tests/ Drupal/ Tests/ Core/ Entity/ KeyValueStore/ KeyValueEntityStorageTest.php - Tests delete.
- KeyValueEntityStorageTest::testLoad in core/
tests/ Drupal/ Tests/ Core/ Entity/ KeyValueStore/ KeyValueEntityStorageTest.php - Tests load.
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ KeyValueStore/ KeyValueEntityStorageTest.php, line 642
Class
Namespace
Drupal\Tests\Core\Entity\KeyValueStoreCode
protected function getMockEntity(string $class = EntityBaseTest::class, array $arguments = [], array $methods = []) : EntityInterface&MockObject {
// 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->getMockBuilder($class)
->setConstructorArgs($arguments)
->onlyMethods($methods)
->getMock();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.