public function TermResourceTestBase::testGetTermWithParent in Drupal 8
Same name and namespace in other branches
- 9 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 333
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);
}