Ejemplo n.º 1
0
 /**
  * Validate that correct output is produced
  */
 public function validate(Result $result)
 {
     if (!$this->regexp->isMatch($result->getOutput())) {
         return new ReturnObj\Failure("Failed asserting that output '{$result->getOutput()}' matches {$this->regexp}");
     }
     return new ReturnObj\Success("Asserted that output '{$result->getOutput()}' matches {$this->regexp}");
 }
Ejemplo n.º 2
0
 /**
  * Validate that correct value is returned
  */
 public function validate(Result $result)
 {
     $return = $this->makeString($result->getReturnValue());
     if (!$this->regexp->isMatch($return)) {
         return new ReturnObj\Failure("Failed asserting that return value matches {$this->regexp}");
     }
     return new ReturnObj\Success("Asserted that return value matches {$this->regexp}");
 }
 /**
  * Validate that the correct exception is thrown
  */
 public function validate(Result $result)
 {
     $exception = $result->getException();
     if (is_null($exception)) {
         return new ReturnObj\Failure("Failed asserting that exception {$this->exceptionClass} was thrown");
     }
     if (!$exception instanceof $this->exceptionClass) {
         return new ReturnObj\Failure("Failed asserting that exception {$this->exceptionClass} was thrown, found: " . get_class($exception));
     }
     return new ReturnObj\Success("Asserted that exception {$this->exceptionClass} was thrown");
 }