本文整理汇总了PHP中PhpSpec\Loader\Node\ExampleNode::getFunctionReflection方法的典型用法代码示例。如果您正苦于以下问题:PHP ExampleNode::getFunctionReflection方法的具体用法?PHP ExampleNode::getFunctionReflection怎么用?PHP ExampleNode::getFunctionReflection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpSpec\Loader\Node\ExampleNode
的用法示例。
在下文中一共展示了ExampleNode::getFunctionReflection方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare
/**
* 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;
}
示例2: prepare
/**
* @param ExampleNode $example
* @param SpecificationInterface $context
* @param MatcherManager $matchers
* @param CollaboratorManager $collaborators
*/
public function prepare(ExampleNode $example, SpecificationInterface $context, MatcherManager $matchers, CollaboratorManager $collaborators)
{
$this->prophet = new Prophet(null, $this->unwrapper, null);
$classRefl = $example->getSpecification()->getClassReflection();
if ($classRefl->hasMethod('let')) {
$this->generateCollaborators($collaborators, $classRefl->getMethod('let'));
}
$this->generateCollaborators($collaborators, $example->getFunctionReflection());
}
示例3: supports
/**
* @param ExampleNode $example
*
* @return bool
*/
public function supports(ExampleNode $example)
{
$parser = new Parser();
$this->beforeMethod = $parser->getBeforeMethodName($example->getFunctionReflection());
if (!isset($this->beforeMethod)) {
return false;
}
return $example->getSpecification()->getClassReflection()->hasMethod($this->beforeMethod);
}
示例4: prepareExampleBeforeAnnotation
function prepareExampleBeforeAnnotation(ExampleNode $exampleNode, \ReflectionMethod $method, SpecificationNode $specificationNode, \ReflectionClass $specClass)
{
$exampleNode->getFunctionReflection()->willReturn($method);
$method->getDocComment()->willReturn(<<<ANNOTATION
/**
* @before prepareMethod
*/
ANNOTATION
);
$exampleNode->getSpecification()->willReturn($specificationNode);
$specificationNode->getClassReflection()->willReturn($specClass);
}
示例5:
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);
}
示例6: array
function it_runs_let_and_letgo_maintainer_before_and_after_each_example_if_the_example_throws_an_exception(ExampleNode $example, SpecificationNode $specification, ReflectionClass $specReflection, $context, ReflectionMethod $exampReflection, LetAndLetgoMaintainer $maintainer, SpecificationInterface $context)
{
$example->isPending()->willReturn(false);
$example->getFunctionReflection()->willReturn($exampReflection);
$example->getSpecification()->willReturn($specification);
$specification->getClassReflection()->willReturn($specReflection);
$specReflection->newInstanceArgs()->willReturn($context);
$exampReflection->getParameters()->willReturn(array());
$exampReflection->invokeArgs($context, array())->willThrow('RuntimeException');
$maintainer->getPriority()->willReturn(1);
$maintainer->supports($example)->willReturn(true);
$maintainer->prepare($example, Argument::cetera())->shouldBeCalled();
$maintainer->teardown($example, Argument::cetera())->shouldBeCalled();
$this->registerMaintainer($maintainer);
$this->run($example);
}
示例7: getIterators
private function getIterators(ExampleNode $example)
{
$classRefl = $example->getSpecification()->getClassReflection();
if ($classRefl->hasMethod('let')) {
foreach ($classRefl->getMethod('let')->getParameters() as $parameter) {
if ($this->isIterator($parameter->getClass())) {
(yield $parameter->getName() => $parameter->getClass()->getName());
}
}
}
foreach ($example->getFunctionReflection()->getParameters() as $parameter) {
if ($this->isIterator($parameter->getClass())) {
(yield $parameter->getName() => $parameter->getClass()->getName());
}
}
}
示例8: PendingException
function it_outputs_exceptions_for_failed_examples(SuiteEvent $event, ExampleEvent $pendingEvent, IO $io, StatisticsCollector $stats, SpecificationNode $specification, ExampleNode $example, ReflectionFunctionAbstract $reflectionFunction)
{
$reflectionFunction->getStartLine()->willReturn(37);
$example->getFunctionReflection()->willReturn($reflectionFunction);
$example->getTitle()->willReturn('it tests something');
$pendingEvent->getException()->willReturn(new PendingException());
$pendingEvent->getSpecification()->willReturn($specification);
$pendingEvent->getExample()->willReturn($example);
$stats->getEventsCount()->willReturn(1);
$stats->getFailedEvents()->willReturn(array());
$stats->getBrokenEvents()->willReturn(array());
$stats->getPendingEvents()->willReturn(array($pendingEvent));
$stats->getSkippedEvents()->willReturn(array());
$stats->getTotalSpecs()->willReturn(1);
$stats->getCountsHash()->willReturn(array('passed' => 0, 'pending' => 1, 'skipped' => 0, 'failed' => 0, 'broken' => 0));
$this->afterSuite($event);
$expected = '<lineno> 37</lineno> <pending>- it tests something</pending>';
$io->writeln($expected)->shouldHaveBeenCalled();
}
示例9: getDataFromProvider
/**
* @param ExampleNode $example
* @return bool|mixed
*/
private function getDataFromProvider(ExampleNode $example)
{
$parser = new Parser();
$dataProviderMethod = $parser->getDataProvider($example->getFunctionReflection());
if (!isset($dataProviderMethod)) {
return array();
}
if (!$example->getSpecification()->getClassReflection()->hasMethod($dataProviderMethod)) {
return array();
}
$subject = $example->getSpecification()->getClassReflection()->newInstance();
$providedData = $example->getSpecification()->getClassReflection()->getMethod($dataProviderMethod)->invoke($subject);
return is_array($providedData) ? $providedData : array();
}