function TermResourceTestBase::testGetTermWithParent
Same name in other branches
- 8.9.x core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php \Drupal\Tests\taxonomy\Functional\Rest\TermResourceTestBase::testGetTermWithParent()
- 10 core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php \Drupal\Tests\taxonomy\Functional\Rest\TermResourceTestBase::testGetTermWithParent()
- 11.x core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php \Drupal\Tests\taxonomy\Functional\Rest\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 334
Class
Namespace
Drupal\Tests\taxonomy\Functional\RestCode
public function testGetTermWithParent(array $parent_term_ids) {
// Create all possible parent terms.
Term::create([
'vid' => Vocabulary::load('camelids')->id(),
])
->setName('Lamoids')
->save();
Term::create([
'vid' => Vocabulary::load('camelids')->id(),
])
->setName('Wimoids')
->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.