private function processSubject(SubjectMetadata $subject, $annotation) { if ($annotation instanceof Annotations\BeforeMethods) { $subject->setBeforeMethods($this->resolveValue($annotation, $subject->getBeforeMethods(), $annotation->getMethods())); } if ($annotation instanceof Annotations\AfterMethods) { $subject->setAfterMethods($this->resolveValue($annotation, $subject->getAfterMethods(), $annotation->getMethods())); } if ($annotation instanceof Annotations\ParamProviders) { $subject->setParamProviders($this->resolveValue($annotation, $subject->getParamProviders(), $annotation->getProviders())); } if ($annotation instanceof Annotations\Iterations) { $subject->setIterations($annotation->getIterations()); } if ($annotation instanceof Annotations\Sleep) { $subject->setSleep($annotation->getSleep()); } if ($annotation instanceof Annotations\Groups) { $subject->setGroups($this->resolveValue($annotation, $subject->getGroups(), $annotation->getGroups())); } if ($annotation instanceof Annotations\Revs) { $subject->setRevs($annotation->getRevs()); } if ($annotation instanceof Annotations\Warmup) { $subject->setWarmup($annotation->getRevs()); } if ($annotation instanceof Annotations\Skip) { $subject->setSkip(true); } if ($annotation instanceof Annotations\OutputTimeUnit) { $subject->setOutputTimeUnit($annotation->getTimeUnit()); $subject->setOutputTimePrecision($annotation->getPrecision()); } if ($annotation instanceof Annotations\OutputMode) { $subject->setOutputMode($annotation->getMode()); } }
/** * It should skip subjects that should be skipped. */ public function testSkip() { $subject1 = new SubjectMetadata($this->benchmark->reveal(), 'one', 0); $subject2 = new SubjectMetadata($this->benchmark->reveal(), 'two', 0); $subject3 = new SubjectMetadata($this->benchmark->reveal(), 'three', 0); $subject2->setSkip(true); $this->benchmark->getSubjects()->willReturn([$subject1, $subject2, $subject3]); TestUtil::configureBenchmarkMetadata($this->benchmark); $this->executor->execute($subject1, Argument::cetera())->will($this->loadIterationResultCallback()); $this->executor->execute($subject2, Argument::cetera())->will($this->loadIterationResultCallback()); $this->executor->execute($subject3, Argument::cetera())->will($this->loadIterationResultCallback()); $suite = $this->runner->run(new RunnerContext(__DIR__)); $this->assertInstanceOf('PhpBench\\Model\\Suite', $suite); $this->assertNoErrors($suite); $this->assertEquals(2, $suite->getSummary()->getNbSubjects()); $subjects = $suite->getSubjects(); $this->assertEquals('one', $subjects[0]->getName()); $this->assertEquals('three', $subjects[1]->getName()); $this->executor->execute($subject2, Argument::cetera())->shouldNotHaveBeenCalled(); }