function ComponentRenderTest::testPluginDefinition

Same name in this branch
  1. 11.x core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php \Drupal\KernelTests\Components\ComponentRenderTest::testPluginDefinition()
Same name in other branches
  1. 10 core/modules/sdc/tests/src/Kernel/ComponentRenderTest.php \Drupal\Tests\sdc\Kernel\ComponentRenderTest::testPluginDefinition()
  2. 10 core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php \Drupal\KernelTests\Components\ComponentRenderTest::testPluginDefinition()

Ensures some key aspects of the plugin definition are correctly computed.

Throws

\Drupal\Component\Plugin\Exception\PluginNotFoundException

File

core/modules/sdc/tests/src/Kernel/ComponentRenderTest.php, line 360

Class

ComponentRenderTest
Tests the correct rendering of components.

Namespace

Drupal\Tests\sdc\Kernel

Code

public function testPluginDefinition() : void {
    $plugin_manager = \Drupal::service('plugin.manager.sdc');
    assert($plugin_manager instanceof ComponentPluginManager);
    $definition = $plugin_manager->getDefinition('sdc_test:my-banner');
    $this->assertSame('my-banner', $definition['machineName']);
    $this->assertStringEndsWith('sdc/tests/modules/sdc_test/components/my-banner', $definition['path']);
    $this->assertEquals([
        'core/drupal',
    ], $definition['library']['dependencies']);
    $this->assertNotEmpty($definition['library']['css']['component']);
    $this->assertSame('my-banner.twig', $definition['template']);
    $this->assertNotEmpty($definition['documentation']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.