コード例 #1
0
 /**
  * @inheritdoc
  */
 protected function validateValue($value)
 {
     $valid = true;
     try {
         $calculator = new Calculator();
         $calculator->calc($value);
     } catch (CalculatorException $e) {
         $valid = false;
     }
     return $valid ? null : [$this->message, []];
 }
コード例 #2
0
ファイル: CalculatorTest.php プロジェクト: zhuravljov/calc
 private function assertCalcException($expression, $code)
 {
     $calculator = new Calculator();
     try {
         $calculator->calc($expression);
     } catch (CalculatorException $e) {
         if ($e->getCode() === $code) {
             return;
         } else {
             $this->fail('Exception code must be ' . $code . ', not ' . $e->getCode() . '.');
         }
     }
     $this->fail('An expected exception has not been raised.');
 }