Esempio n. 1
0
 public function testColors()
 {
     if (posix_isatty(STDOUT)) {
         $this->assertEqual(TipyCli::black('text'), "text");
         $this->assertEqual(TipyCli::red('text'), "text");
         $this->assertEqual(TipyCli::green('text'), "text");
         $this->assertEqual(TipyCli::brown('text'), "text");
         $this->assertEqual(TipyCli::blue('text'), "text");
         $this->assertEqual(TipyCli::purple('text'), "text");
         $this->assertEqual(TipyCli::cyan('text'), "text");
         $this->assertEqual(TipyCli::lightGray('text'), "text");
         $this->assertEqual(TipyCli::darkGray('text'), "text");
         $this->assertEqual(TipyCli::lightRed('text'), "text");
         $this->assertEqual(TipyCli::lightGreen('text'), "text");
         $this->assertEqual(TipyCli::yellow('text'), "text");
         $this->assertEqual(TipyCli::lightBlue('text'), "text");
         $this->assertEqual(TipyCli::lightPurple('text'), "text");
         $this->assertEqual(TipyCli::lightCyan('text'), "text");
         $this->assertEqual(TipyCli::white('text'), "text");
     } else {
         $this->assertEqual(TipyCli::black('text'), "text");
         $this->assertEqual(TipyCli::red('text'), "text");
         $this->assertEqual(TipyCli::green('text'), "text");
         $this->assertEqual(TipyCli::brown('text'), "text");
         $this->assertEqual(TipyCli::blue('text'), "text");
         $this->assertEqual(TipyCli::purple('text'), "text");
         $this->assertEqual(TipyCli::cyan('text'), "text");
         $this->assertEqual(TipyCli::lightGray('text'), "text");
         $this->assertEqual(TipyCli::darkGray('text'), "text");
         $this->assertEqual(TipyCli::lightRed('text'), "text");
         $this->assertEqual(TipyCli::lightGreen('text'), "text");
         $this->assertEqual(TipyCli::yellow('text'), "text");
         $this->assertEqual(TipyCli::lightBlue('text'), "text");
         $this->assertEqual(TipyCli::lightPurple('text'), "text");
         $this->assertEqual(TipyCli::lightCyan('text'), "text");
         $this->assertEqual(TipyCli::white('text'), "text");
     }
 }
Esempio n. 2
0
 private function printSummary()
 {
     echo PHP_EOL . PHP_EOL;
     echo "Tests: " . $this->tests;
     echo ", Assertions: " . $this->assertions;
     echo ", Failures: " . sizeof($this->failures);
     echo ", Exceptions: " . sizeof($this->exceptions);
     echo PHP_EOL . PHP_EOL;
     if (sizeof($this->failures) > 0) {
         echo TipyCli::red('Failures:') . PHP_EOL;
         $i = 0;
         foreach ($this->failures as $e) {
             $i++;
             echo $i . ") ";
             $trace = $e->getTrace();
             if ($trace[2]['function'] == "{closure}") {
                 $test = $trace[1];
                 $testBody = $trace[0];
             } else {
                 $test = $trace[2];
                 $testBody = $trace[1];
             }
             echo TipyCli::yellow($test['function']) . ": ";
             echo $testBody['file'] . " at line (" . TipyCli::cyan($testBody['line']) . ")" . PHP_EOL;
             echo $e->getMessage();
             echo PHP_EOL . PHP_EOL;
         }
     }
     if (sizeof($this->exceptions) > 0) {
         echo TipyCli::red('Exceptions:') . PHP_EOL;
         $i = 0;
         foreach ($this->exceptions as $e) {
             $i++;
             echo $i . ") ";
             $trace = $e->getTrace();
             echo TipyCli::yellow($trace[0]['function']) . ": ";
             echo $e->getFile() . " at line (" . TipyCli::cyan($e->getLine()) . ")" . PHP_EOL;
             echo get_class($e) . ": " . $e->getMessage() . PHP_EOL;
             echo $e->getTraceAsString();
             echo PHP_EOL . PHP_EOL;
         }
     }
 }