function ResourceTypeTest::testUpdateDeprecatedFieldMapping

Tests construction of a ResourceType using a deprecated $fields argument.

@group legacy @expectedDeprecation Passing an array with strings or booleans as a field mapping to Drupal\jsonapi\ResourceType\ResourceType::__construct() is deprecated in Drupal 8.8.0 and will not be allowed in Drupal 9.0.0. See \Drupal\jsonapi\ResourceTypeRepository::getFields(). See https://www.drupal.org/node/3084746. @covers ::__construct @covers ::updateDeprecatedFieldMapping

File

core/modules/jsonapi/tests/src/Kernel/ResourceType/ResourceTypeTest.php, line 36

Class

ResourceTypeTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21jsonapi%21src%21ResourceType%21ResourceType.php/class/ResourceType/8.9.x" title="Value object containing all metadata for a JSON:API resource type." class="local">\Drupal\jsonapi\ResourceType\ResourceType</a> @group jsonapi

Namespace

Drupal\Tests\jsonapi\Kernel\ResourceType

Code

public function testUpdateDeprecatedFieldMapping() {
    $deprecated_field_mapping = [
        'uid' => 'author',
        'body' => FALSE,
    ];
    $resource_type = new ResourceType('node', 'article', Node::class, FALSE, TRUE, TRUE, FALSE, $deprecated_field_mapping);
    $this->assertSame('author', $resource_type->getFieldByInternalName('uid')
        ->getPublicName());
    $this->assertFalse($resource_type->getFieldByInternalName('body')
        ->isFieldEnabled());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.