DerivativeTest.php

Same filename and directory in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Plugin/DerivativeTest.php
  2. 10 core/tests/Drupal/KernelTests/Core/Plugin/DerivativeTest.php
  3. 11.x core/tests/Drupal/KernelTests/Core/Plugin/DerivativeTest.php

Namespace

Drupal\KernelTests\Core\Plugin

File

core/tests/Drupal/KernelTests/Core/Plugin/DerivativeTest.php

View source
<?php

namespace Drupal\KernelTests\Core\Plugin;


/**
 * Tests that derivative plugins are correctly discovered.
 *
 * @group Plugin
 */
class DerivativeTest extends PluginTestBase {
    
    /**
     * {@inheritdoc}
     */
    public static $modules = [
        'node',
        'user',
    ];
    
    /**
     * Tests getDefinitions() and getDefinition() with a derivativeDecorator.
     */
    public function testDerivativeDecorator() {
        // Ensure that getDefinitions() returns the expected definitions.
        $this->assertEqual($this->mockBlockManager
            ->getDefinitions(), $this->mockBlockExpectedDefinitions);
        // Ensure that getDefinition() returns the expected definition.
        foreach ($this->mockBlockExpectedDefinitions as $id => $definition) {
            $this->assertEqual($this->mockBlockManager
                ->getDefinition($id), $definition);
        }
        // Ensure that NULL is returned as the definition of a non-existing base
        // plugin, a non-existing derivative plugin, or a base plugin that may not
        // be used without deriving.
        $this->assertIdentical($this->mockBlockManager
            ->getDefinition('non_existing', FALSE), NULL, 'NULL returned as the definition of a non-existing base plugin.');
        $this->assertIdentical($this->mockBlockManager
            ->getDefinition('menu:non_existing', FALSE), NULL, 'NULL returned as the definition of a non-existing derivative plugin.');
        $this->assertIdentical($this->mockBlockManager
            ->getDefinition('menu', FALSE), NULL, 'NULL returned as the definition of a base plugin that may not be used without deriving.');
    }

}

Classes

Title Deprecated Summary
DerivativeTest Tests that derivative plugins are correctly discovered.

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