class TypedDefinitionEnsuringPluginDiscoveryDecoratorTest in Plugin 8.2
@coversDefaultClass \Drupal\plugin\PluginDiscovery\TypedDefinitionEnsuringPluginDiscoveryDecorator
@group Plugin
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\plugin\Unit\PluginDiscovery\TypedDefinitionEnsuringPluginDiscoveryDecoratorTest
Expanded class hierarchy of TypedDefinitionEnsuringPluginDiscoveryDecoratorTest
File
- tests/
src/ Unit/ PluginDiscovery/ TypedDefinitionEnsuringPluginDiscoveryDecoratorTest.php, line 16
Namespace
Drupal\Tests\plugin\Unit\PluginDiscoveryView source
class TypedDefinitionEnsuringPluginDiscoveryDecoratorTest extends UnitTestCase {
/**
* The original plugin manager.
*
* @var \Drupal\Component\Plugin\PluginManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $pluginManager;
/**
* The type of the plugin definitions to decorate.
*
* @var \Drupal\plugin\PluginType\PluginTypeInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $pluginType;
/**
* The class under test.
*
* @var \Drupal\plugin\PluginDiscovery\TypedDefinitionEnsuringPluginDiscoveryDecorator
*/
protected $sut;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
$this->pluginManager = $this
->createMock(PluginManagerInterface::class);
$this->pluginType = $this
->createMock(PluginTypeInterface::class);
$this->sut = new TypedDefinitionEnsuringPluginDiscoveryDecorator($this->pluginType, $this->pluginManager);
}
/**
* @covers ::__construct
*/
public function testConstruct() {
$this->sut = new TypedDefinitionEnsuringPluginDiscoveryDecorator($this->pluginType, $this->pluginManager);
$this
->assertInstanceOf(TypedDefinitionEnsuringPluginDiscoveryDecorator::class, $this->sut);
}
/**
* @covers ::getDefinitions
* @covers ::processDecoratedDefinitions
*/
public function testGetDefinitions() {
$decorated_plugin_id_a = $this
->randomMachineName();
$decorated_plugin_definition_a = [
'id' => $decorated_plugin_id_a,
];
$decorated_plugin_id_b = $this
->randomMachineName();
$decorated_plugin_definition_b = [
'id' => $decorated_plugin_id_b,
];
$decorated_plugin_definitions = [
$decorated_plugin_id_a => $decorated_plugin_definition_a,
$decorated_plugin_id_b => $decorated_plugin_definition_b,
];
$this->pluginManager
->expects($this
->once())
->method('getDefinitions')
->willReturn($decorated_plugin_definitions);
$typed_plugin_definition_a = $this
->createMock(PluginDefinitionInterface::class);
$typed_plugin_definition_b = $this
->createMock(PluginDefinitionInterface::class);
$map = [
[
$decorated_plugin_definition_a,
$typed_plugin_definition_a,
],
[
$decorated_plugin_definition_b,
$typed_plugin_definition_b,
],
];
$this->pluginType
->expects($this
->atLeastOnce())
->method('ensureTypedPluginDefinition')
->willReturnMap($map);
$expected_plugin_definitions = [
$decorated_plugin_id_a => $typed_plugin_definition_a,
$decorated_plugin_id_b => $typed_plugin_definition_b,
];
$this
->assertSame($expected_plugin_definitions, $this->sut
->getDefinitions());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
TypedDefinitionEnsuringPluginDiscoveryDecoratorTest:: |
protected | property | The original plugin manager. | |
TypedDefinitionEnsuringPluginDiscoveryDecoratorTest:: |
protected | property | The type of the plugin definitions to decorate. | |
TypedDefinitionEnsuringPluginDiscoveryDecoratorTest:: |
protected | property | The class under test. | |
TypedDefinitionEnsuringPluginDiscoveryDecoratorTest:: |
protected | function |
Overrides UnitTestCase:: |
|
TypedDefinitionEnsuringPluginDiscoveryDecoratorTest:: |
public | function | @covers ::__construct | |
TypedDefinitionEnsuringPluginDiscoveryDecoratorTest:: |
public | function | @covers ::getDefinitions @covers ::processDecoratedDefinitions | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |