protected function ResourceTestBase::getSparseFieldSets in JSON:API 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getSparseFieldSets()
Returns an array of sparse fields sets to test.
Return value
array An array of sparse field sets (an array of field names), keyed by a label for the field set.
2 calls to ResourceTestBase::getSparseFieldSets()
- EntityTestTest::getSparseFieldSets in tests/src/ Functional/ EntityTestTest.php 
- Returns an array of sparse fields sets to test.
- ResourceTestBase::doTestSparseFieldSets in tests/src/ Functional/ ResourceTestBase.php 
- Tests sparse field sets.
1 method overrides ResourceTestBase::getSparseFieldSets()
- EntityTestTest::getSparseFieldSets in tests/src/ Functional/ EntityTestTest.php 
- Returns an array of sparse fields sets to test.
File
- tests/src/ Functional/ ResourceTestBase.php, line 2706 
Class
- ResourceTestBase
- Subclass this for every JSON API resource type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected function getSparseFieldSets() {
  $field_names = array_keys($this->entity
    ->toArray());
  $field_sets = [
    'empty' => [],
    'some' => array_slice($field_names, floor(count($field_names) / 2)),
    'all' => $field_names,
  ];
  if ($this->entity instanceof EntityOwnerInterface) {
    $field_sets['nested_empty_fieldset'] = $field_sets['empty'];
    $field_sets['nested_fieldset_with_owner_fieldset'] = [
      'name',
      'created',
    ];
  }
  return $field_sets;
}