class PluginBaseTest
Tests Drupal\Component\Plugin\PluginBase.
Attributes
#[CoversClass(PluginBase::class)]
#[Group('Plugin')]
Hierarchy
- class \Drupal\Tests\Component\Plugin\PluginBaseTest extends \PHPUnit\Framework\TestCase
Expanded class hierarchy of PluginBaseTest
File
-
core/
tests/ Drupal/ Tests/ Component/ Plugin/ PluginBaseTest.php, line 16
Namespace
Drupal\Tests\Component\PluginView source
class PluginBaseTest extends TestCase {
/**
* Tests get plugin id.
*
* @legacy-covers ::getPluginId
*/
public function testGetPluginId($plugin_id, $expected) : void {
$plugin_base = new StubPluginBase([], $plugin_id, []);
$this->assertEquals($expected, $plugin_base->getPluginId());
}
/**
* Returns test data for testGetPluginId().
*
* @return array
* An array of test cases, where each item contains a plugin ID and
* the expected plugin ID result.
*/
public static function providerTestGetPluginId() {
return [
[
'base_id',
'base_id',
],
[
'base_id:derivative',
'base_id:derivative',
],
];
}
/**
* Tests get base id.
*
* @coves ::getBaseId
*/
public function testGetBaseId($plugin_id, $expected) : void {
$plugin_base = new StubPluginBase([], $plugin_id, []);
$this->assertEquals($expected, $plugin_base->getBaseId());
}
/**
* Returns test data for testGetBaseId().
*
* @return array
* An array of test cases, where each item contains a plugin ID and
* the expected base ID result.
*/
public static function providerTestGetBaseId() {
return [
[
'base_id',
'base_id',
],
[
'base_id:derivative',
'base_id',
],
];
}
/**
* Tests get derivative id.
*
* @legacy-covers ::getDerivativeId
*/
public function testGetDerivativeId($plugin_id = NULL, $expected = NULL) : void {
$plugin_base = new StubPluginBase([], $plugin_id, []);
$this->assertEquals($expected, $plugin_base->getDerivativeId());
}
/**
* Returns test data for testGetDerivativeId().
*
* @return array
* An array of test cases, where each item contains a plugin ID and
* the expected derivative ID result.
*/
public static function providerTestGetDerivativeId() {
return [
[
'base_id',
NULL,
],
[
'base_id:derivative',
'derivative',
],
];
}
/**
* Tests get plugin definition.
*
* @legacy-covers ::getPluginDefinition
*/
public function testGetPluginDefinition() : void {
$plugin_base = new StubPluginBase([], 'plugin_id', [
'value',
[
'key' => 'value',
],
]);
$this->assertEquals([
'value',
[
'key' => 'value',
],
], $plugin_base->getPluginDefinition());
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary |
|---|---|---|---|
| PluginBaseTest::providerTestGetBaseId | public static | function | Returns test data for testGetBaseId(). |
| PluginBaseTest::providerTestGetDerivativeId | public static | function | Returns test data for testGetDerivativeId(). |
| PluginBaseTest::providerTestGetPluginId | public static | function | Returns test data for testGetPluginId(). |
| PluginBaseTest::testGetBaseId | public | function | Tests get base id. |
| PluginBaseTest::testGetDerivativeId | public | function | Tests get derivative id. |
| PluginBaseTest::testGetPluginDefinition | public | function | Tests get plugin definition. |
| PluginBaseTest::testGetPluginId | public | function | Tests get plugin id. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.