You are here

protected function RulesComponentActionTest::prophesizeStorage in Rules 8.3

Prepares a mocked entity storage that returns the provided Rules configs.

Parameters

\Drupal\rules\Entity\RulesComponentConfig[] $rules_configs: The Rules component configuration entities that should be returned.

5 calls to RulesComponentActionTest::prophesizeStorage()
RulesComponentActionTest::testActionAvailable in tests/src/Unit/Integration/RulesAction/RulesComponentActionTest.php
Tests that a rule can be used as action.
RulesComponentActionTest::testAutosaveOnlyOnce in tests/src/Unit/Integration/RulesAction/RulesComponentActionTest.php
Tests that auto saving is only triggered once with nested components.
RulesComponentActionTest::testContextDefinitions in tests/src/Unit/Integration/RulesAction/RulesComponentActionTest.php
Tests that context definitions are available on the derived action.
RulesComponentActionTest::testExecute in tests/src/Unit/Integration/RulesAction/RulesComponentActionTest.php
Tests that the execution of the action invokes the Rules component.
RulesComponentActionTest::testExecutionProvidedVariables in tests/src/Unit/Integration/RulesAction/RulesComponentActionTest.php
Tests that a rules component in an action can also provide variables.

File

tests/src/Unit/Integration/RulesAction/RulesComponentActionTest.php, line 180

Class

RulesComponentActionTest
Tests for exposing Rules components as action plugins.

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

protected function prophesizeStorage(array $rules_configs) {
  $storage = $this
    ->prophesize(ConfigEntityStorageInterface::class);
  $keyed_configs = [];
  foreach ($rules_configs as $rules_config) {
    $keyed_configs[$rules_config
      ->id()] = $rules_config;
    $storage
      ->load($rules_config
      ->id())
      ->willReturn($rules_config);
  }
  $storage
    ->loadMultiple(NULL)
    ->willReturn($keyed_configs);
  $this->entityTypeManager
    ->getStorage('rules_component')
    ->willReturn($storage
    ->reveal());
}