public function ConfigEntityCalculateDependencyTest::testBusinessRulesItemObjectCalculateDependencies in Business Rules 8
Same name and namespace in other branches
- 2.x tests/src/Unit/ConfigEntityCalculateDependencyTest.php \Drupal\Tests\business_rules\Unit\ConfigEntityCalculateDependencyTest::testBusinessRulesItemObjectCalculateDependencies()
@covers \Drupal\business_rules\Entity\BusinessRulesItemBase::calculateDependencies
File
- tests/
src/ Unit/ ConfigEntityCalculateDependencyTest.php, line 234
Class
- ConfigEntityCalculateDependencyTest
- Test dependencies calculation.
Namespace
Drupal\Tests\business_rules\UnitCode
public function testBusinessRulesItemObjectCalculateDependencies() {
$this->businessRulesConditionManager
->expects($this
->any())
->method('getDefinition')
->willReturnMap([
[
'user_variable_has_role',
TRUE,
[
'class' => UserVariableHasRole::class,
'id' => 'user_variable_has_role',
],
],
]);
$condition = new Condition([
'type' => 'user_variable_has_role',
'settings' => [
'user_variable' => 'test_variable',
],
]);
$dependencies = $condition
->calculateDependencies()
->getDependencies();
$this
->assertEquals([
'business_rules.variable.test_variable',
], $dependencies['config']);
$dependencyA = new BusinessRulesItemObject('test_action_a', 'action', 0);
$condition
->addSuccessItem($dependencyA);
$dependencies = $condition
->calculateDependencies()
->getDependencies();
$this
->assertEquals([
'business_rules.action.test_action_a',
'business_rules.variable.test_variable',
], $dependencies['config']);
}