You are here

class Validator in Workbench Moderation 8.2

Same name and namespace in other branches
  1. 8 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 242

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
StateTransitionValidation::$possibleTransitions protected property Stores the possible state transitions.
StateTransitionValidation::$queryFactory protected property
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
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 @inheritDoc Overrides StateTransitionValidation::getTransitionFromStates