Parkour\TraverseTest::closure PHP Method

closure() private method

Returns a closure constrained by the given values.
See also: https://phpunit.de/manual/current/en/test-doubles.html#test-doubles.stubs.examples.StubTest5.php
See also: https://phpunit.de/manual/current/en/test-doubles.html#test-doubles.mock-objects.examples.with-consecutive.php
private closure ( array $values, integer $calls = null ) : Closure
$values array Values.
$calls integer Number of expected calls.
return Closure Closure.
    private function closure(array $values, $calls = null)
    {
        if ($calls === null) {
            $calls = count($values);
        }
        $Mock = $this->getMock('stdClass', ['method']);
        $Mocker = $Mock->expects($this->exactly($calls));
        $Mocker->method('method');
        $Mocker->will($this->returnValueMap($values));
        $with = array_map(function ($arguments) {
            return array_slice($arguments, 0, -1);
        }, $values);
        $Matcher = new ConsecutiveParameters($with);
        $Mocker->getMatcher()->parametersMatcher = $Matcher;
        $Reflection = new ReflectionClass($Mock);
        $Method = $Reflection->getMethod('method');
        return $Method->getClosure($Mock);
    }