public function ConfigActionsServiceTest::testListAll in Config Actions 8
@covers ::listAll @covers ::listActions
File
- tests/
src/ Kernel/ ConfigActionsServiceTest.php, line 62
Class
- ConfigActionsServiceTest
- test the ConfigActions service
Namespace
Drupal\Tests\config_actions\KernelCode
public function testListAll() {
// Test listing all modules with actions.
$list = $this->configActions
->listAll();
self::assertNotNull($list['test_config_actions'], $list);
// Test listing specific modules with actions.
$list = $this->configActions
->listAll('test_config_actions');
self::assertArrayHasKey('test_config_actions', $list);
self::assertArrayHasKey('field_template_action', $list['test_config_actions']);
self::assertArrayHasKey('core.date_format.short', $list['test_config_actions']);
// Test a module that doesn't have any actions of its own.
$list = $this->configActions
->listAll('config_actions');
self::assertArrayNotHasKey('config_actions', $list);
// Test listing specific file in modules with actions.
$list = $this->configActions
->listAll('test_config_actions', 'field_template_action');
self::assertArrayHasKey('test_config_actions', $list);
self::assertArrayHasKey('field_template_action', $list['test_config_actions']);
// Shouldn't see actions in a different file
self::assertArrayNotHasKey('core.date_format.short', $list['test_config_actions']);
// Look at return data for specific actions and sub-actions
$action_names = array_keys($list['test_config_actions']['field_template_action']);
self::assertEquals([
'field_storage',
'field_instance:article',
'field_instance:page',
], $action_names);
}