PhpBench\Model\Variant::setException PHP Method

setException() public method

Should be called when an Exception is encountered during the execution of any of the iteration processes. After an exception is encountered the results from this iteration set are invalid.
public setException ( Exception $exception )
$exception Exception
    public function setException(\Exception $exception)
    {
        $errors = [];
        do {
            $errors[] = Error::fromException($exception);
        } while ($exception = $exception->getPrevious());
        $this->errorStack = new ErrorStack($this, $errors);
    }

Usage Example

コード例 #1
0
ファイル: VariantTest.php プロジェクト: dantleech/phpbench
 /**
  * It should throw an exception if getStats is called when an exception has been set.
  *
  * @expectedException RuntimeException
  * @expectedExceptionMessage Cannot retrieve stats when an exception
  */
 public function testGetStatsWithExceptionException()
 {
     $variant = new Variant($this->subject->reveal(), $this->parameterSet->reveal(), 4, 20);
     $this->subject->getRetryThreshold()->willReturn(10);
     $variant->createIteration(TestUtil::createResults(4, 10));
     $variant->createIteration(TestUtil::createResults(4, 10));
     $variant->createIteration(TestUtil::createResults(4, 10));
     $variant->createIteration(TestUtil::createResults(4, 10));
     $variant->computeStats();
     $variant->setException(new \Exception('Test'));
     $variant->getStats();
 }