function ResourceTypeRepositoryTest::testMappingNameConflictCheck
Ensures that a naming conflict in mapping causes an exception to be thrown.
@legacy-covers ::getFields
Attributes
#[DataProvider('getFieldsProvider')]
File
-
core/
modules/ jsonapi/ tests/ src/ Kernel/ ResourceType/ ResourceTypeRepositoryTest.php, line 139
Class
Namespace
Drupal\Tests\jsonapi\Kernel\ResourceTypeCode
public function testMappingNameConflictCheck($field_name_list) : void {
$entity_type = \Drupal::entityTypeManager()->getDefinition('node');
$bundle = 'article';
$reflection_class = new \ReflectionClass($this->resourceTypeRepository);
$reflection_method = $reflection_class->getMethod('getFields');
$this->expectException(\LogicException::class);
$this->expectExceptionMessage("The generated alias '{$field_name_list[1]}' for field name '{$field_name_list[0]}' conflicts with an existing field. Report this in the JSON:API issue queue!");
$reflection_method->invokeArgs($this->resourceTypeRepository, [
$field_name_list,
$entity_type,
$bundle,
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.