function EntityConverterTest::testConvertWithInvalidEntityType
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityConverterTest::testConvertWithInvalidEntityType()
- 10 core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityConverterTest::testConvertWithInvalidEntityType()
- 8.9.x core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityConverterTest::testConvertWithInvalidEntityType()
Tests the convert() method with an invalid entity type.
File
-
core/
tests/ Drupal/ Tests/ Core/ ParamConverter/ EntityConverterTest.php, line 219
Class
- EntityConverterTest
- @coversDefaultClass \Drupal\Core\ParamConverter\EntityConverter[[api-linebreak]] @group ParamConverter @group Entity
Namespace
Drupal\Tests\Core\ParamConverterCode
public function testConvertWithInvalidEntityType() {
$this->setUpMocks();
$contexts = [
EntityRepositoryInterface::CONTEXT_ID_LEGACY_CONTEXT_OPERATION => new Context(new ContextDefinition('string'), 'entity_upcast'),
];
$plugin_id = 'invalid_id';
$this->entityRepository
->expects($this->once())
->method('getCanonical')
->with($plugin_id, 'id', $contexts)
->willThrowException(new PluginNotFoundException($plugin_id));
$this->expectException(PluginNotFoundException::class);
$this->entityConverter
->convert('id', [
'type' => 'entity:' . $plugin_id,
], 'foo', [
'foo' => 'id',
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.