PhpBench\Tests\Util\TestUtil::configureSubjectMetadata PHP Method

configureSubjectMetadata() public static method

public static configureSubjectMetadata ( Prophecy\Prophecy\ObjectProphecy $subject, array $options = [] )
$subject Prophecy\Prophecy\ObjectProphecy
$options array
    public static function configureSubjectMetadata(ObjectProphecy $subject, array $options = [])
    {
        $options = array_merge(['iterations' => 1, 'name' => 'benchFoo', 'beforeMethods' => [], 'afterMethods' => [], 'parameterSets' => [[[]]], 'groups' => [], 'revs' => 1, 'warmup' => 0, 'notApplicable' => false, 'skip' => false, 'sleep' => 0, 'paramProviders' => [], 'outputTimeUnit' => 'microseconds', 'outputMode' => 'time'], $options);
        $subject->getIterations()->willReturn($options['iterations']);
        $subject->getSleep()->willReturn($options['sleep']);
        $subject->getName()->willReturn($options['name']);
        $subject->getBeforeMethods()->willReturn($options['beforeMethods']);
        $subject->getAfterMethods()->willReturn($options['afterMethods']);
        $subject->getParameterSets()->willReturn($options['parameterSets']);
        $subject->getGroups()->willReturn($options['groups']);
        $subject->getRevs()->willReturn($options['revs']);
        $subject->getSkip()->willReturn($options['skip']);
        $subject->getWarmup()->willReturn($options['warmup']);
        $subject->getParamProviders()->willReturn($options['paramProviders']);
        $subject->getOutputTimeUnit()->willReturn($options['outputTimeUnit']);
        $subject->getOutputMode()->willReturn($options['outputMode']);
    }

Usage Example

示例#1
0
 /**
  * It should throw an exception if the parameters are not in a valid format.
  *
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage Each parameter set must be an array, got "string" for TestBench::benchTest
  */
 public function testInvalidParameters()
 {
     $this->hierarchy->isEmpty()->willReturn(false);
     $this->metadata->getSubjects()->willReturn([$this->subjectMetadata->reveal()]);
     TestUtil::configureBenchmarkMetadata($this->metadata, ['class' => 'TestBench', 'path' => self::PATH]);
     TestUtil::configureSubjectMetadata($this->subjectMetadata, ['name' => 'benchTest']);
     $this->reflector->getParameterSets(self::PATH, [])->willReturn(['asd' => 'bar']);
     $this->factory->getMetadataForFile(self::FNAME);
 }