function CategorizingPluginManagerTraitTest::testProcessDefinitionCategory

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/CategorizingPluginManagerTraitTest.php \Drupal\Tests\Core\Plugin\CategorizingPluginManagerTraitTest::testProcessDefinitionCategory()
  2. 10 core/tests/Drupal/Tests/Core/Plugin/CategorizingPluginManagerTraitTest.php \Drupal\Tests\Core\Plugin\CategorizingPluginManagerTraitTest::testProcessDefinitionCategory()
  3. 11.x core/tests/Drupal/Tests/Core/Plugin/CategorizingPluginManagerTraitTest.php \Drupal\Tests\Core\Plugin\CategorizingPluginManagerTraitTest::testProcessDefinitionCategory()

@covers ::processDefinitionCategory

File

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

Class

CategorizingPluginManagerTraitTest
@coversDefaultClass \Drupal\Core\Plugin\CategorizingPluginManagerTrait @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.