public function testColors() { if (posix_isatty(STDOUT)) { $this->assertEqual(TipyCli::black('text'), "[0;30mtext[0m"); $this->assertEqual(TipyCli::red('text'), "[0;31mtext[0m"); $this->assertEqual(TipyCli::green('text'), "[0;32mtext[0m"); $this->assertEqual(TipyCli::brown('text'), "[0;33mtext[0m"); $this->assertEqual(TipyCli::blue('text'), "[0;34mtext[0m"); $this->assertEqual(TipyCli::purple('text'), "[0;35mtext[0m"); $this->assertEqual(TipyCli::cyan('text'), "[0;36mtext[0m"); $this->assertEqual(TipyCli::lightGray('text'), "[0;37mtext[0m"); $this->assertEqual(TipyCli::darkGray('text'), "[1;30mtext[0m"); $this->assertEqual(TipyCli::lightRed('text'), "[1;31mtext[0m"); $this->assertEqual(TipyCli::lightGreen('text'), "[1;32mtext[0m"); $this->assertEqual(TipyCli::yellow('text'), "[1;33mtext[0m"); $this->assertEqual(TipyCli::lightBlue('text'), "[1;34mtext[0m"); $this->assertEqual(TipyCli::lightPurple('text'), "[1;35mtext[0m"); $this->assertEqual(TipyCli::lightCyan('text'), "[1;36mtext[0m"); $this->assertEqual(TipyCli::white('text'), "[1;37mtext[0m"); } 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"); } }
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; } } }