Commit 66258696 authored by larowlan's avatar larowlan

Issue #3085885 by gabesullice, e0ipso, Wim Leers: Follow-up to #3014277: Wrong...

Issue #3085885 by gabesullice, e0ipso, Wim Leers: Follow-up to #3014277: Wrong variable used as argument in BC layer-providing ResourceType::updateDeprecatedFieldMapping()
parent dc7b06ca
......@@ -501,7 +501,7 @@ private function updateDeprecatedFieldMapping(array $field_mapping, $entity_type
/** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */
$entity_type_manager = \Drupal::service('entity_type.manager');
$is_fieldable = $entity_type_manager->getDefinition($entity_type_manager)->entityClassImplements(FieldableEntityInterface::class);
$is_fieldable = $entity_type_manager->getDefinition($entity_type_id)->entityClassImplements(FieldableEntityInterface::class);
$field_definitions = $is_fieldable
? \Drupal::service('entity_field.manager')->getFieldDefinitions($entity_type_id, $bundle)
: [];
......
<?php
namespace Drupal\Tests\jsonapi\Kernel\ResourceType;
use Drupal\jsonapi\ResourceType\ResourceType;
use Drupal\KernelTests\KernelTestBase;
use Drupal\node\Entity\Node;
/**
* @coversDefaultClass \Drupal\jsonapi\ResourceType\ResourceType
* @group jsonapi
*
* @internal
*/
class ResourceTypeTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'serialization',
'jsonapi',
'user',
'text',
'node',
];
/**
* 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
*/
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());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment