class WorkflowDependenciesTest
Same name and namespace in other branches
- 11.x core/modules/workflows/tests/src/Kernel/WorkflowDependenciesTest.php \Drupal\Tests\workflows\Kernel\WorkflowDependenciesTest
Tests configuration dependencies in workflows.
@coversDefaultClass \Drupal\workflows\Entity\Workflow
@group workflows
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\workflows\Kernel\WorkflowDependenciesTest implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of WorkflowDependenciesTest
File
-
core/
modules/ workflows/ tests/ src/ Kernel/ WorkflowDependenciesTest.php, line 15
Namespace
Drupal\Tests\workflows\KernelView source
class WorkflowDependenciesTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
'workflows',
'workflow_type_test',
'workflow_third_party_settings_test',
];
/**
* Tests \Drupal\workflows\Entity\Workflow::onDependencyRemoval().
*/
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']);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.