You are here

public function ResourceTypeTest::testUpdateDeprecatedFieldMapping in Drupal 8

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 \Drupal\jsonapi\ResourceType\ResourceType @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());
}