You are here

class Validator in Workbench Moderation 8

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

Testable subclass for selected tests.

EntityQuery is beyond untestable, so we have to subclass and override the method that uses it.

Hierarchy

Expanded class hierarchy of Validator

File

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

Namespace

Drupal\Tests\workbench_moderation\Unit
View source
class Validator extends StateTransitionValidation {

  /**
   * {@inheritdoc}
   */
  protected function getTransitionFromStates($from, $to) {
    if ($from == 'draft' && $to == 'draft') {
      return $this
        ->transitionStorage()
        ->loadMultiple([
        'draft__draft',
      ])[0];
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StateTransitionValidation::$entityTypeManager protected property The entity type manager service.
StateTransitionValidation::$possibleTransitions protected property Stores the possible state transitions.
StateTransitionValidation::calculatePossibleTransitions protected function Computes a mapping of possible transitions.
StateTransitionValidation::getPossibleTransitions protected function Returns a mapping of possible transitions.
StateTransitionValidation::getTransitionsFrom protected function Returns a list of transitions from a given state.
StateTransitionValidation::getValidTransitions public function Gets a list of transitions that are legal for this user on this entity.
StateTransitionValidation::getValidTransitionTargets public function Gets a list of states a user may transition an entity to.
StateTransitionValidation::isTransitionAllowed public function Determines a transition allowed.
StateTransitionValidation::loadBundleEntity protected function Loads a specific bundle entity.
StateTransitionValidation::stateStorage protected function Returns the state entity storage service.
StateTransitionValidation::transitionStateQuery protected function Generates an entity query for transition states.
StateTransitionValidation::transitionStorage protected function Returns the transition entity storage service.
StateTransitionValidation::userMayTransition public function Determines if a user is allowed to transition from one state to another.
StateTransitionValidation::__construct public function Constructs a new StateTransitionValidation.
Validator::getTransitionFromStates protected function Returns the transition object that transitions from one state to another. Overrides StateTransitionValidation::getTransitionFromStates