You are here

public function PluginTypeTest::testEnsureTypedPluginDefinition in Plugin 8.2

@covers ::ensureTypedPluginDefinition @covers ::createFromDefinition @covers ::__construct

File

tests/src/Unit/PluginType/PluginTypeTest.php, line 159

Class

PluginTypeTest
@coversDefaultClass \Drupal\plugin\PluginType\PluginType

Namespace

Drupal\Tests\plugin\Unit\PluginType

Code

public function testEnsureTypedPluginDefinition() {
  $decorated_plugin_definition = [
    'foo' => $this
      ->randomMachineName(),
  ];
  $this->pluginTypeDefinition['plugin_definition_decorator_class'] = ArrayPluginDefinitionDecorator::class;
  $this->sut = PluginType::createFromDefinition($this->container, $this->pluginTypeDefinition);
  $typed_plugin_definition = $this->sut
    ->ensureTypedPluginDefinition($decorated_plugin_definition);
  $this
    ->assertInstanceOf(PluginDefinitionInterface::class, $typed_plugin_definition);

  // We use ArrayPluginDefinitionDecorator for testing. The following
  // assertion makes sure the method under test correctly passes on the
  // decorated plugin definition to the decorator. The array handling is not
  // part of this test.

  /** @var \Drupal\plugin\PluginDefinition\ArrayPluginDefinitionDecorator $typed_plugin_definition */
  $this
    ->assertSame($decorated_plugin_definition, $typed_plugin_definition
    ->getArrayDefinition());
}