Пример #1
0
 /**
  * Make the assertion and report result to the test runner.
  * 
  * @param $type         string  Either property or method
  * @param $name         string  Name of the property/method
  * @param $expectation  boolean
  */
 private function assert($expectation, $type, $value)
 {
     if ($this->negate) {
         $expectation = !$expectation;
         $not = " not ";
     } else {
         $not = " ";
     }
     $subject = CLI::toString($this->subject);
     if (!$expectation) {
         $this->runner->addError("Expected {$subject} to{$not}have {$type} {$value}.");
         $this->runner->markCurrentAsFailed();
     }
 }
Пример #2
0
 /**
  * Make the assertion and report result to the test runner.
  * 
  * @param $expectation  boolean
  * @param $type         string
  * @param $value        
  */
 private function assert($expectation, $type, $value)
 {
     $not = $this->negate ? " not " : " ";
     $subject = CLI::toString($this->subject);
     $value = CLI::toString($value);
     if (!$expectation) {
         $this->runner->addError("Expected {$subject} to{$not}contain {$type} {$value}.");
         $this->runner->markCurrentAsFailed();
     }
 }
Пример #3
0
 /**
  * Run all tests.
  */
 public function run()
 {
     echo CLI::color("blue", "\nLimerence ");
     echo CLI::color("grey", "v{$this->version}\n");
     echo "\nTests:\n‾‾‾‾‾‾";
     $time = microtime();
     foreach ($this->testSuites as $testSuite) {
         $this->testSuite = $testSuite;
         $this->testSuite->gatherTestCases();
     }
     foreach ($this->testSuites as $testSuite) {
         $this->testSuite = $testSuite;
         $this->testSuite->run();
     }
     if ($this->errors) {
         echo CLI::color("red", "\n\nErrors:\n‾‾‾‾‾‾‾\n");
         foreach ($this->errors as $error) {
             echo "{$error}\n\n";
         }
     }
     $this->time = microtime() - $time;
     $numberOfTests = $this->passing + $this->failing;
     echo "\n\n{$numberOfTests} tests ({$this->assertions} assertions) completed in " . number_format($this->time, 2) . " ms.\n\n";
     echo CLI::color("green", "{$this->passing} tests passing.\n");
     echo CLI::color("red", "{$this->failing} tests failing.\n\n");
 }
Пример #4
0
 /**
  * Make the assertion and report result to the test runner.
  * 
  * @param $expectation  boolean     Success
  * @param $type         string      Subject type
  * @param $value        string      Expected type
  */
 private function assert($expectation, $type, $value = "")
 {
     $subject = CLI::toString($this->subject);
     if ($this->negate) {
         $expectation = !$expectation;
         $not = " not ";
     } else {
         $not = " ";
     }
     if (!$expectation) {
         $message = "Expected {$subject} to{$not}be {$type}";
         if ($value && !$this->negate) {
             $message .= ", but is a {$value}.";
         } else {
             $message .= ".";
         }
         $this->runner->addError($message);
         $this->runner->markCurrentAsFailed();
     }
 }
Пример #5
0
 /**
  * Make the assertion and report result to the test runner.
  */
 private function assert()
 {
     if ($this->negate) {
         $expectation = $this->subject != $this->expectation;
         $not = " not ";
     } else {
         $expectation = $this->subject == $this->expectation;
         $not = " ";
     }
     $subject = CLI::toString($this->subject);
     $value = CLI::toString($this->expectation);
     if (!$expectation) {
         $this->runner->addError("Expected {$subject} to{$not}equal {$value}");
         $this->runner->markCurrentAsFailed();
     }
 }
Пример #6
0
 public function __toString()
 {
     $mark = $this->success === true ? CLI::color("green", "✔") : CLI::color("red", "✘");
     $expectation = CLI::color("grey", $this->expectation);
     return "      {$mark} {$expectation}\n";
 }
Пример #7
0
 /**
  * Get the error as a string.
  * 
  * @return string
  */
 public function __toString()
 {
     return CLI::color("grey", "   {$this->description}\n") . "   – {$this->message}";
 }