StateTransitionValidation example

    $user->hasPermission($permission)->willReturn($allowed);
    $user->hasPermission(Argument::type('string'))->willReturn(FALSE);

    $entity = $this->prophesize(ContentEntityInterface::class);
    $entity = $entity->reveal();
    $entity->moderation_state = new \stdClass();
    $entity->moderation_state->value = $from_id;

    $moderation_info = $this->prophesize(ModerationInformationInterface::class);
    $moderation_info->getWorkflowForEntity($entity)->willReturn($this->workflow);

    $validator = new StateTransitionValidation($moderation_info->reveal());
    $has_transition = FALSE;
    foreach ($validator->getValidTransitions($entity$user->reveal()) as $transition) {
      if ($transition->to()->id() === $to_id) {
        $has_transition = TRUE;
        break;
      }
    }
    $this->assertSame($result$has_transition);
  }

  /** * Data provider for the user transition test. */
Home | Imprint | This part of the site doesn't use cookies.