protected function EntityUsageTest::insertEntityUsage in Entity Usage 8.2
Inserts a row into the usage table.
Parameters
\Drupal\Core\Entity\EntityInterface $source: The source entity.
\Drupal\Core\Entity\EntityInterface $target: The target entity.
2 calls to EntityUsageTest::insertEntityUsage()
- EntityUsageTest::testlistSources in tests/
src/ Kernel/ EntityUsageTest.php - Tests the listSources() and listTargets() method.
- EntityUsageTest::testListTargetRevisions in tests/
src/ Kernel/ EntityUsageTest.php - Tests the listTargets() method using the revision option.
File
- tests/
src/ Kernel/ EntityUsageTest.php, line 241
Class
- EntityUsageTest
- Tests the basic API operations of our tracking service.
Namespace
Drupal\Tests\entity_usage\KernelCode
protected function insertEntityUsage(EntityInterface $source, EntityInterface $target, string $field_name) {
$source_vid = $source instanceof RevisionableInterface && $source
->getRevisionId() ? $source
->getRevisionId() : 0;
$this->injectedDatabase
->insert($this->tableName)
->fields([
'target_id' => $target
->id(),
'target_type' => $target
->getEntityTypeId(),
'source_id' => $source
->id(),
'source_type' => $source
->getEntityTypeId(),
'source_langcode' => $source
->language()
->getId(),
'source_vid' => $source_vid,
'method' => 'entity_reference',
'field_name' => $field_name,
'count' => 1,
])
->execute();
}