コード例 #1
0
ファイル: CliTest.php プロジェクト: smetana/tipy
 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");
     }
 }
コード例 #2
0
ファイル: TipyTestUnit.php プロジェクト: smetana/tipy
 /**
  * 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();
     }
 }