You are here

public function ConfigEntityCalculateDependencyTest::testActionCalculateDependencies in Business Rules 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/ConfigEntityCalculateDependencyTest.php \Drupal\Tests\business_rules\Unit\ConfigEntityCalculateDependencyTest::testActionCalculateDependencies()

@covers \Drupal\business_rules\Entity\Condition::calculateDependencies

File

tests/src/Unit/ConfigEntityCalculateDependencyTest.php, line 138

Class

ConfigEntityCalculateDependencyTest
Test dependencies calculation.

Namespace

Drupal\Tests\business_rules\Unit

Code

public function testActionCalculateDependencies() {
  $this->businessRulesActionManager
    ->expects($this
    ->any())
    ->method('getDefinition')
    ->willReturnMap([
    [
      'action_set',
      TRUE,
      [
        'class' => ActionSet::class,
        'id' => 'action_set',
      ],
    ],
  ]);
  $action = new Action([
    'type' => 'action_set',
  ]);
  $dependencies = $action
    ->calculateDependencies()
    ->getDependencies();
  $this
    ->assertArrayNotHasKey('config', $dependencies);
  $action
    ->setSetting('items', [
    'test_action_a' => [
      'weight' => 0,
      'type' => 'action',
      'id' => 'test_action_a',
    ],
  ]);
  $dependencies = $action
    ->calculateDependencies()
    ->getDependencies();
  $this
    ->assertEquals([
    'business_rules.action.test_action_a',
  ], $dependencies['config']);
  $action
    ->setSetting('items', [
    'test_action_a' => [
      'weight' => 0,
      'type' => 'action',
      'id' => 'test_action_a',
    ],
    'test_action_b' => [
      'weight' => 0,
      'type' => 'action',
      'id' => 'test_action_b',
    ],
  ]);
  $dependencies = $action
    ->calculateDependencies()
    ->getDependencies();
  $this
    ->assertEquals([
    'business_rules.action.test_action_a',
    'business_rules.action.test_action_b',
  ], $dependencies['config']);
}