function NodeTest::testDeprecatedEntityReferenceFieldItem
Tests deprecated entity reference items.
@group legacy
File
-
core/
modules/ jsonapi/ tests/ src/ Functional/ NodeTest.php, line 517
Class
- NodeTest
- JSON:API integration test for the "Node" content entity type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
public function testDeprecatedEntityReferenceFieldItem() : void {
\Drupal::service('module_installer')->install([
'jsonapi_test_reference_types',
]);
$this->setUpAuthorization('GET');
// @todo Remove line below in favor of commented line in https://www.drupal.org/project/drupal/issues/2878463.
$url = Url::fromRoute(sprintf('jsonapi.%s.individual', static::$resourceTypeName), [
'entity' => $this->entity
->uuid(),
]);
// $url = $this->entity->toUrl('jsonapi');
$query = [
'include' => 'deprecated_reference',
];
$url->setOption('query', $query);
$request_options = [];
$request_options[RequestOptions::HEADERS]['Accept'] = 'application/vnd.api+json';
$request_options = NestedArray::mergeDeep($request_options, $this->getAuthenticationRequestOptions());
$this->expectDeprecation('Entity reference field items not implementing Drupal\\Core\\Field\\Plugin\\Field\\FieldType\\EntityReferenceItemInterface is deprecated in drupal:10.2.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3279140');
$this->request('GET', $url, $request_options);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.