function EntityConverterTest::testConvertWithInvalidEntityType

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityConverterTest::testConvertWithInvalidEntityType()
  2. 8.9.x core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityConverterTest::testConvertWithInvalidEntityType()
  3. 10 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 212

Class

EntityConverterTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21ParamConverter%21EntityConverter.php/class/EntityConverter/11.x" title="Parameter converter for upcasting entity IDs to full objects." class="local">\Drupal\Core\ParamConverter\EntityConverter</a> @group ParamConverter @group Entity

Namespace

Drupal\Tests\Core\ParamConverter

Code

public function testConvertWithInvalidEntityType() : void {
    $this->setUpMocks();
    $plugin_id = 'invalid_id';
    $contexts = [
        'operation' => 'entity_upcast',
    ];
    $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.