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"); } }
/** * Run test suite * * Execute all <b>test*</b> methods from test suite * and collect results */ public function run() { $className = get_class($this); $methods = get_class_methods($className); foreach ($methods as $testName) { if (!preg_match("/^test/", $testName)) { continue; } $this->tests++; $this->clearAppContext(); $this->setUp(); $testClosure = function () use($testName) { try { $this->{$testName}(); echo TipyCli::green('.'); } catch (AssertionFailedException $e) { $this->failures[] = $e; echo TipyCli::purple('F'); } catch (Exception $e) { $this->exceptions[] = $e; echo TipyCli::red('E'); } }; if ($this->transactionalFixtures) { TipyDAO::transaction(function () use($testName, $testClosure) { $testClosure(); TipyDAO::rollback(); }); } else { $testClosure(); } $this->tearDown(); } }