You are here

protected function StateTransitionValidationTest::setupTransitionStorage in Workbench Moderation 8

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/StateTransitionValidationTest.php \Drupal\Tests\workbench_moderation\Unit\StateTransitionValidationTest::setupTransitionStorage()

Builds a mock storage object for Transitions.

Return value

\Drupal\Core\Entity\EntityStorageInterface Returns an entity storage config.

1 call to StateTransitionValidationTest::setupTransitionStorage()
StateTransitionValidationTest::setupEntityTypeManager in tests/src/Unit/StateTransitionValidationTest.php
Builds a mocked Entity Type Manager.

File

tests/src/Unit/StateTransitionValidationTest.php, line 26

Class

StateTransitionValidationTest
@coversDefaultClass \Drupal\workbench_moderation\StateTransitionValidation @group workbench_moderation

Namespace

Drupal\Tests\workbench_moderation\Unit

Code

protected function setupTransitionStorage() {
  $entity_storage = $this
    ->prophesize(EntityStorageInterface::class);
  $list = $this
    ->setupTransitionEntityList();
  $entity_storage
    ->loadMultiple()
    ->willReturn($list);
  $entity_storage
    ->loadMultiple(Argument::type('array'))
    ->will(function ($args) use ($list) {
    $keys = $args[0];
    if (empty($keys)) {
      return $list;
    }
    $return = array_map(function ($key) use ($list) {
      return $list[$key];
    }, $keys);
    return $return;
  });
  return $entity_storage
    ->reveal();
}