Eris\Shrinker\Random::from PHP Метод

from() публичный Метод

Precondition: $values should fail $this->assertion
public from ( GeneratedValue $elements, PHPUnit_Framework_AssertionFailedError $exception )
$elements Eris\Generator\GeneratedValue
$exception PHPUnit_Framework_AssertionFailedError
    public function from(GeneratedValue $elements, AssertionFailed $exception)
    {
        $onBadShrink = function () use(&$exception) {
            $this->attempts->increase();
            $this->attempts->ensureLimit($exception);
        };
        $onGoodShrink = function ($elementsAfterShrink, $exceptionAfterShrink) use(&$elements, &$exception) {
            $this->attempts->reset();
            $elements = $elementsAfterShrink;
            $exception = $exceptionAfterShrink;
        };
        $this->timeLimit->start();
        while (!$this->timeLimit->hasBeenReached()) {
            $elementsAfterShrink = $this->generator->shrink($elements);
            if ($elementsAfterShrink == $elements) {
                $onBadShrink();
                continue;
            }
            if (!$this->checkGoodShrinkConditions($elementsAfterShrink)) {
                $onBadShrink();
                continue;
            }
            foreach ($this->onAttempt as $onAttempt) {
                $onAttempt($elementsAfterShrink);
            }
            Evaluation::of($this->assertion)->with($elementsAfterShrink)->onFailure($onGoodShrink)->onSuccess($onBadShrink)->execute();
        }
        throw new \RuntimeException("Eris has reached the time limit for shrinking ({$this->timeLimit}), here it is presenting the simplest failure case." . PHP_EOL . "If you can afford to spend more time to find a simpler failing input, increase it with \$this->shrinkingTimeLimit(\$seconds).", -1, $exception);
    }