class ConfigActionsPluginBaseTest in Config Actions 8
test the ConfigActionsPluginBase class
@coversDefaultClass \Drupal\config_actions\ConfigActionsPluginBase @group config_actions
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\config_actions\Unit\ConfigActionsPluginBaseTest
Expanded class hierarchy of ConfigActionsPluginBaseTest
File
- tests/
src/ Unit/ ConfigActionsPluginBaseTest.php, line 16
Namespace
Drupal\Tests\config_actions\UnitView source
class ConfigActionsPluginBaseTest extends UnitTestCase {
/**
* @var \Drupal\config_actions\ConfigActionsServiceInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $configActions;
/**
* Annotation data to be passed to plugin constructor.
* @var array
*/
protected $definition;
public function setUp() {
parent::setUp();
$container = new ContainerBuilder();
$this->configActions = $this
->createMock(ConfigActionsServiceInterface::class);
$container
->set('config_actions', $this->configActions);
\Drupal::setContainer($container);
$this->definition = [
'options' => [],
'replace_in' => [],
'data' => [],
];
}
/**
* @covers ::setOptions
* @covers ::getOption
*/
public function testGetOption() {
$options = [
'source' => 'my source',
];
$plugin = new ConfigActionsPluginBase($options, 'test', $this->definition, $this->configActions);
$plugin
->setOptions($options);
$this
->assertEquals('my source', $plugin
->getOption('source'));
}
/**
* @covers ::setOptions
*/
public function testSetOptions() {
$options = [
'source' => 'node.type.@bundle@',
'replace' => [
'@bundle@' => 'article',
],
];
$this->definition['replace_in'] = [
'source',
];
$plugin = new ConfigActionsPluginBase($options, 'test', $this->definition, $this->configActions);
$plugin
->setOptions($options);
$this
->assertEquals('node.type.article', $plugin
->getOption('source'));
}
/**
* @covers ::parseOptions
*/
public function testParseOptions() {
$options = [
'id' => 'testid',
'source' => '@id@',
];
$plugin = new ConfigActionsPluginBase($options, 'test', $this->definition, $this->configActions);
$new_options = $plugin
->parseOptions($options);
$this
->assertEquals('testid', $new_options['source']);
}
/**
* @covers ::setOptions
*/
public function testSimpleOptions() {
$options = [
'source' => 'node.type.@bundle@',
'@bundle@' => 'article',
];
$this->definition['replace_in'] = [
'source',
];
$plugin = new ConfigActionsPluginBase($options, 'test', $this->definition, $this->configActions);
$plugin
->setOptions($options);
$this
->assertEquals('node.type.article', $plugin
->getOption('source'));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigActionsPluginBaseTest:: |
protected | property | ||
ConfigActionsPluginBaseTest:: |
protected | property | Annotation data to be passed to plugin constructor. | |
ConfigActionsPluginBaseTest:: |
public | function |
Overrides UnitTestCase:: |
|
ConfigActionsPluginBaseTest:: |
public | function | @covers ::setOptions @covers ::getOption | |
ConfigActionsPluginBaseTest:: |
public | function | @covers ::parseOptions | |
ConfigActionsPluginBaseTest:: |
public | function | @covers ::setOptions | |
ConfigActionsPluginBaseTest:: |
public | function | @covers ::setOptions | |
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. | |
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. |