function TermResourceTestBase::testGetTermWithParent
Tests GETting a term with a parent term other than the default <root> (0).
@dataProvider providerTestGetTermWithParent
See also
::getExpectedNormalizedEntity()
File
- 
              core/
modules/ taxonomy/ tests/ src/ Functional/ Rest/ TermResourceTestBase.php, line 346  
Class
Namespace
Drupal\Tests\taxonomy\Functional\RestCode
public function testGetTermWithParent(array $parent_term_ids) : void {
  // Create all possible parent terms.
  Term::create([
    'vid' => Vocabulary::load('camelids')->id(),
  ])
    ->setName('Lamoids')
    ->save();
  Term::create([
    'vid' => Vocabulary::load('camelids')->id(),
  ])
    ->setName('Camels')
    ->save();
  // Modify the entity under test to use the provided parent terms.
  $this->entity
    ->set('parent', $parent_term_ids)
    ->save();
  $this->initAuthentication();
  $url = $this->getEntityResourceUrl();
  $url->setOption('query', [
    '_format' => static::$format,
  ]);
  $request_options = $this->getAuthenticationRequestOptions('GET');
  $this->provisionEntityResource();
  $this->setUpAuthorization('GET');
  $response = $this->request('GET', $url, $request_options);
  $expected = $this->getExpectedNormalizedEntity();
  static::recursiveKSort($expected);
  $actual = $this->serializer
    ->decode((string) $response->getBody(), static::$format);
  static::recursiveKSort($actual);
  $this->assertSame($expected, $actual);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.