function CategorizingPluginManagerTraitTest::testProcessDefinitionCategory

@covers ::processDefinitionCategory

File

core/tests/Drupal/Tests/Core/Plugin/CategorizingPluginManagerTraitTest.php, line 77

Class

CategorizingPluginManagerTraitTest
@coversDefaultClass \Drupal\Core\Plugin\CategorizingPluginManagerTrait[[api-linebreak]] @group Plugin

Namespace

Drupal\Tests\Core\Plugin

Code

public function testProcessDefinitionCategory() {
  // Existing category.
  $definition = [
    'label' => 'some',
    'provider' => 'core',
    'category' => 'bag',
  ];
  $this->pluginManager
    ->processDefinition($definition, 'some');
  $this->assertSame('bag', $definition['category']);
  // No category, provider without label.
  $definition = [
    'label' => 'some',
    'provider' => 'core',
  ];
  $this->pluginManager
    ->processDefinition($definition, 'some');
  $this->assertSame('core', $definition['category']);
  // No category, provider is module with label.
  $definition = [
    'label' => 'some',
    'provider' => 'node',
  ];
  $this->pluginManager
    ->processDefinition($definition, 'some');
  $this->assertSame('Node', $definition['category']);
}

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