/** * Generates DI related stuff via parameter validator * * @param ExampleNode $example * @param Specification $context * @param MatcherManager $matchers * @param CollaboratorManager $collaborators * * @return $this */ public function prepare(ExampleNode $example, Specification $context, MatcherManager $matchers, CollaboratorManager $collaborators) { if ($example->getSpecification()->getClassReflection()->hasMethod('let')) { $this->parameterValidator->validate($example->getSpecification()->getClassReflection()->getMethod('let')); } $this->parameterValidator->validate($example->getFunctionReflection()); return $this; }
function it_does_pass_regular_example_into_parameter_validator_and_let_method_if_they_are_defined(ExampleNode $example, Specification $context, MatcherManager $matchers, CollaboratorManager $collaborators, SpecificationNode $specificationNode, \ReflectionClass $reflectionClass) { $example->getSpecification()->willReturn($specificationNode); $specificationNode->getClassReflection()->willReturn($reflectionClass); $reflectionClass->hasMethod('let')->willReturn(true); $exampleClosureReflection = new \ReflectionFunction(function () { }); $letClosureReflection = new \ReflectionFunction(function () { }); $reflectionClass->getMethod('let')->willReturn($letClosureReflection)->shouldBeCalled(); $example->getFunctionReflection()->willReturn($exampleClosureReflection)->shouldBeCalled(); $this->parameterValidator->validate($letClosureReflection)->shouldBeCalled(); $this->parameterValidator->validate($exampleClosureReflection)->shouldBeCalled(); $this->prepare($example, $context, $matchers, $collaborators)->shouldReturn($this); }