protected function ConfigEntityCalculateDependencyTest::setUp in Business Rules 8
Same name and namespace in other branches
- 2.x tests/src/Unit/ConfigEntityCalculateDependencyTest.php \Drupal\Tests\business_rules\Unit\ConfigEntityCalculateDependencyTest::setUp()
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ ConfigEntityCalculateDependencyTest.php, line 53
Class
- ConfigEntityCalculateDependencyTest
- Test dependencies calculation.
Namespace
Drupal\Tests\business_rules\UnitCode
protected function setUp() {
$entityStorage = $this
->createMock(EntityStorageInterface::class);
$entityTypeManager = $this
->createMock(EntityTypeManagerInterface::class);
$this->businessRulesActionManager = $this
->createMock(BusinessRulesActionManager::class);
$this->businessRulesConditionManager = $this
->createMock(BusinessRulesConditionManager::class);
$container = new ContainerBuilder();
$container
->set('uuid', $this
->createMock(UuidInterface::class));
$container
->set('event_dispatcher', $this
->createMock(EventDispatcherInterface::class));
$container
->set('config.factory', $this
->createMock(ConfigFactoryInterface::class));
$container
->set('entity_type.manager', $entityTypeManager);
$container
->set('entity_type.repository', $this
->createMock(EntityTypeRepositoryInterface::class));
$container
->set('business_rules.processor', $this
->createMock(BusinessRulesProcessor::class));
$container
->set('business_rules.util', $this
->createMock(BusinessRulesUtil::class));
$container
->set('plugin.manager.business_rules.action', $this->businessRulesActionManager);
$container
->set('plugin.manager.business_rules.condition', $this->businessRulesConditionManager);
$container
->set('plugin.manager.business_rules.reacts_on', $this
->createMock(BusinessRulesReactsOnManager::class));
$container
->set('plugin.manager.business_rules.variable', $this
->createMock(BusinessRulesVariableManager::class));
$businessRulesUtil = $this
->createMock(BusinessRulesUtil::class);
$businessRulesUtil->container = $container;
$container
->set('business_rules.util', $businessRulesUtil);
\Drupal::setContainer($container);
$actionAConfigEntity = $this
->createMock(Action::class);
$actionAConfigEntity
->expects($this
->any())
->method('getConfigDependencyName')
->willReturn('business_rules.action.test_action_a');
$actionBConfigEntity = $this
->createMock(Action::class);
$actionBConfigEntity
->expects($this
->any())
->method('getConfigDependencyName')
->willReturn('business_rules.action.test_action_b');
$conditionAConfigEntity = $this
->createMock(Condition::class);
$conditionAConfigEntity
->expects($this
->any())
->method('getConfigDependencyName')
->willReturn('business_rules.condition.test_condition_a');
$conditionBConfigEntity = $this
->createMock(Condition::class);
$conditionBConfigEntity
->expects($this
->any())
->method('getConfigDependencyName')
->willReturn('business_rules.condition.test_condition_b');
$variableConfigEntity = $this
->createMock(Variable::class);
$variableConfigEntity
->expects($this
->any())
->method('getConfigDependencyName')
->willReturn('business_rules.variable.test_variable');
$entityTypeManager
->expects($this
->any())
->method('getStorage')
->willReturn($entityStorage);
$entityStorage
->expects($this
->any())
->method('load')
->willReturnMap([
[
'test_action_a',
$actionAConfigEntity,
],
[
'test_action_b',
$actionBConfigEntity,
],
[
'test_condition_a',
$conditionAConfigEntity,
],
[
'test_condition_b',
$conditionBConfigEntity,
],
[
'test_variable',
$variableConfigEntity,
],
]);
}