public function WorkflowDependenciesTest::testOnDependencyRemoval in Drupal 8
Same name and namespace in other branches
- 9 core/modules/workflows/tests/src/Kernel/WorkflowDependenciesTest.php \Drupal\Tests\workflows\Kernel\WorkflowDependenciesTest::testOnDependencyRemoval()
Tests \Drupal\workflows\Entity\Workflow::onDependencyRemoval().
File
- core/
modules/ workflows/ tests/ src/ Kernel/ WorkflowDependenciesTest.php, line 30
Class
- WorkflowDependenciesTest
- Tests configuration dependencies in workflows.
Namespace
Drupal\Tests\workflows\KernelCode
public function testOnDependencyRemoval() {
// Create a workflow that has a dependency on a third party setting.
$workflow = Workflow::create([
'id' => 'test3',
'type' => 'workflow_type_complex_test',
]);
$workflow
->setThirdPartySetting('workflow_third_party_settings_test', 'key', 'value');
$workflow
->save();
$this
->assertSame([
'workflow_third_party_settings_test',
'workflow_type_test',
], $workflow
->getDependencies()['module']);
// Uninstall workflow_third_party_settings_test to ensure
// \Drupal\workflows\Entity\Workflow::onDependencyRemoval() works as
// expected.
\Drupal::service('module_installer')
->uninstall([
'node',
'workflow_third_party_settings_test',
]);
/** @var \Drupal\workflows\WorkflowInterface $workflow */
$workflow = \Drupal::entityTypeManager()
->getStorage('workflow')
->loadUnchanged($workflow
->id());
$this
->assertSame([
'workflow_type_test',
], $workflow
->getDependencies()['module']);
}