public function DeriverTest::testAvailableActionPlugins in Workbench Moderation Actions 8
Checks the correct actions are available.
File
- tests/
src/ Kernel/ DeriverTest.php, line 52 - Tests.
Class
- DeriverTest
- Tests.
Namespace
Drupal\Tests\workbench_moderation_actions\KernelCode
public function testAvailableActionPlugins() {
$bundle = NodeType::create([
'type' => 'test',
]);
$bundle
->setThirdPartySetting('workbench_moderation', 'enabled', TRUE);
$bundle
->setThirdPartySetting('workbench_moderation', 'allowed_moderation_states', [
'archive',
'published',
'draft',
'review',
]);
$bundle
->save();
/** @var \Drupal\Core\Action\ActionManager $action_manager */
$action_manager = \Drupal::service('plugin.manager.action');
$definitions = $action_manager
->getDefinitions();
$definitions_wb = array_filter($definitions, function (array $definition) {
return $definition['provider'] === 'workbench_moderation_actions';
});
$this
->assertCount(4, $definitions_wb);
$this
->assertArrayHasKey('state_change:node__archived', $definitions_wb);
$this
->assertEquals(StateChange::class, $definitions_wb['state_change:node__archived']['class']);
$this
->assertArrayHasKey('state_change:node__draft', $definitions_wb);
$this
->assertEquals(StateChange::class, $definitions_wb['state_change:node__draft']['class']);
$this
->assertArrayHasKey('state_change:node__needs_review', $definitions_wb);
$this
->assertEquals(StateChange::class, $definitions_wb['state_change:node__needs_review']['class']);
$this
->assertArrayHasKey('state_change:node__published', $definitions_wb);
$this
->assertEquals(StateChange::class, $definitions_wb['state_change:node__published']['class']);
}