protected function ResourceTestBase::getRelationshipFieldNames in Drupal 9
Same name and namespace in other branches
- 8 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getRelationshipFieldNames()
Gets a list of public relationship names for the resource type under test.
Parameters
\Drupal\Core\Entity\EntityInterface|null $entity: (optional) The entity for which to get relationship field names.
Return value
array An array of relationship field names.
5 calls to ResourceTestBase::getRelationshipFieldNames()
- ResourceTestBase::doTestIncluded in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php - Tests included resources.
- ResourceTestBase::doTestRelated in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php - Performs one round of related route testing.
- ResourceTestBase::doTestRelationshipGet in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php - Performs one round of relationship route testing.
- ResourceTestBase::getNestedIncludePaths in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php - Gets an array of all nested include paths to be tested.
- ResourceTestBase::testCollection in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php - Tests GETting a collection of resources.
File
- core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php, line 3337
Class
- ResourceTestBase
- Subclass this for every JSON:API resource type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected function getRelationshipFieldNames(EntityInterface $entity = NULL) {
$entity = $entity ?: $this->entity;
// Only content entity types can have relationships.
$fields = $entity instanceof ContentEntityInterface ? iterator_to_array($entity) : [];
return array_reduce($fields, function ($field_names, $field) {
/** @var \Drupal\Core\Field\FieldItemListInterface $field */
if (static::isReferenceFieldDefinition($field
->getFieldDefinition())) {
$field_names[] = $this->resourceType
->getPublicName($field
->getName());
}
return $field_names;
}, []);
}