Example #1
0
 /**
  * Executes the tests depending on our settings
  *
  * @return void
  * @access private
  */
 public function __run()
 {
     $Reporter = new CakeXmlReporter('utf-8', array('app' => $this->Manager->appTest, 'plugin' => $this->Manager->pluginTest, 'group' => $this->type === 'group', 'codeCoverage' => $this->doCoverage));
     if ($this->doCoverage) {
         if (!extension_loaded('xdebug')) {
             $this->out(__('You must install Xdebug to use the CakePHP(tm) Code Coverage Analyzation. Download it from http://www.xdebug.org/docs/install', true));
             $this->_stop(0);
         }
     }
     ob_start();
     try {
         if ($this->type == 'all') {
             $result = $this->Manager->runAllTests($Reporter);
         } else {
             if ($this->type == 'group') {
                 $ucFirstGroup = ucfirst($this->file);
                 if ($this->doCoverage) {
                     require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
                     CodeCoverageManager::init($ucFirstGroup, $Reporter);
                     CodeCoverageManager::start();
                 }
                 $result = $this->Manager->runGroupTest($ucFirstGroup, $Reporter);
             } else {
                 $folder = $folder = $this->__findFolderByCategory($this->category);
                 $case = $this->__getFileName($folder, $this->isPluginTest);
                 if ($this->doCoverage) {
                     require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
                     CodeCoverageManager::init($case, $Reporter);
                     CodeCoverageManager::start();
                 }
                 $result = $this->Manager->runTestCase($case, $Reporter);
             }
         }
     } catch (Exception $e) {
         ob_get_clean();
         $this->out('Tests failed to run. ' . $e->getMessage());
         $this->_stop(1);
     }
     $xml = ob_get_clean();
     $xmlD = new DOMDocument();
     $xmlD->loadXML($xml);
     $xslt = new XSLTProcessor();
     $XSL = new DOMDocument();
     $XSL->load(dirname(__FILE__) . DS . 'xsl' . DS . 'to-junit.xsl');
     $xslt->importStylesheet($XSL);
     $out = $xslt->transformToXML($xmlD);
     $time = time();
     file_put_contents(ROOT . DS . "build" . DS . "logs" . DS . "junit-{$time}.xml", $out);
     echo "Done.\n";
 }
 /**
  * testNoTestCaseSupplied method
  *
  * @access public
  * @return void
  */
 function testNoTestCaseSupplied()
 {
     if (PHP_SAPI != 'cli') {
         unset($_GET['group']);
         CodeCoverageManager::start(substr(md5(microtime()), 0, 5), new CakeHtmlReporter());
         CodeCoverageManager::report(false);
         $this->assertError();
         CodeCoverageManager::start('libs/' . basename(__FILE__), new CakeHtmlReporter());
         CodeCoverageManager::report(false);
         $this->assertError();
         $path = LIBS;
         if (strpos(LIBS, ROOT) === false) {
             $path = ROOT . DS . LIBS;
         }
         App::import('Core', 'Folder');
         $folder = new Folder();
         $folder->cd($path);
         $contents = $folder->ls();
         /**
          * remove method
          *
          * @param mixed $var
          * @access public
          * @return void
          */
         function remove($var)
         {
             return $var != basename(__FILE__);
         }
         $contents[1] = array_filter($contents[1], "remove");
         foreach ($contents[1] as $file) {
             CodeCoverageManager::start('libs' . DS . $file, new CakeHtmlReporter());
             CodeCoverageManager::report(false);
             $this->assertNoErrors('libs' . DS . $file);
         }
     }
 }
Example #3
0
    if ('all' == $_GET['group']) {
        TestManager::runAllTests(CakeTestsGetReporter());
    } else {
        if ($analyzeCodeCoverage) {
            CodeCoverageManager::start($_GET['group'], CakeTestsGetReporter());
        }
        TestManager::runGroupTest(ucfirst($_GET['group']), CakeTestsGetReporter());
        if ($analyzeCodeCoverage) {
            CodeCoverageManager::report();
        }
    }
    CakePHPTestRunMore();
    CakePHPTestAnalyzeCodeCoverage();
} elseif (isset($_GET['case'])) {
    if ($analyzeCodeCoverage) {
        CodeCoverageManager::start($_GET['case'], CakeTestsGetReporter());
    }
    TestManager::runTestCase($_GET['case'], CakeTestsGetReporter());
    if ($analyzeCodeCoverage) {
        CodeCoverageManager::report();
    }
    CakePHPTestRunMore();
    CakePHPTestAnalyzeCodeCoverage();
} elseif (isset($_GET['show']) && $_GET['show'] == 'cases') {
    CakePHPTestCaseList();
} else {
    CakePHPTestGroupTestList();
}
CakePHPTestSuiteFooter();
$output = ob_get_clean();
echo $output;
 /**
  * Paints the beginning of a test method being run.  This is used
  * to start/resume the code coverage tool.
  *
  * @param string $method The method name being run.
  * @return void
  */
 function paintMethodStart($method)
 {
     parent::paintMethodStart($method);
     if (!empty($this->params['codeCoverage'])) {
         CodeCoverageManager::start();
     }
 }
Example #5
0
 /**
  * Executes the tests depending on our settings
  *
  * @return void
  * @access private
  */
 function __run()
 {
     $reporter = new CLIReporter();
     $this->__setGetVars();
     if ($this->type == 'all') {
         return TestManager::runAllTests($reporter);
     }
     if ($this->doCoverage) {
         if (!extension_loaded('xdebug')) {
             $this->out('You must install Xdebug to use the CakePHP(tm) Code Coverage Analyzation. Download it from http://www.xdebug.org/docs/install');
             exit(0);
         }
     }
     if ($this->type == 'group') {
         $ucFirstGroup = ucfirst($this->file);
         $path = CORE_TEST_GROUPS;
         if ($this->category == 'app') {
             $path = APP_TEST_GROUPS;
         } elseif ($this->isPluginTest) {
             $path = APP . 'plugins' . DS . $this->category . DS . 'tests' . DS . 'groups';
         }
         if ($this->doCoverage) {
             require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
             CodeCoverageManager::start($ucFirstGroup, $reporter);
         }
         $result = TestManager::runGroupTest($ucFirstGroup, $reporter);
         if ($this->doCoverage) {
             CodeCoverageManager::report();
         }
         return $result;
     }
     $case = 'libs' . DS . $this->file . '.test.php';
     if ($this->category == 'app') {
         $case = $this->file . '.test.php';
     } elseif ($this->isPluginTest) {
         $case = $this->file . '.test.php';
     }
     if ($this->doCoverage) {
         require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
         CodeCoverageManager::start($case, $reporter);
     }
     $result = TestManager::runTestCase($case, $reporter);
     if ($this->doCoverage) {
         CodeCoverageManager::report();
     }
     return $result;
 }
Example #6
0
 /**
  * Executes the tests depending on our settings
  *
  * @return void
  * @access private
  */
 function __run()
 {
     $Reporter = new CakeCliReporter('utf-8', array('app' => $this->Manager->appTest, 'plugin' => $this->Manager->pluginTest, 'group' => $this->type === 'group', 'codeCoverage' => $this->doCoverage));
     if ($this->type == 'all') {
         return $this->Manager->runAllTests($Reporter);
     }
     if ($this->doCoverage) {
         if (!extension_loaded('xdebug')) {
             $this->out(__('You must install Xdebug to use the CakePHP(tm) Code Coverage Analyzation. Download it from http://www.xdebug.org/docs/install', true));
             $this->_stop(0);
         }
     }
     if ($this->type == 'group') {
         $ucFirstGroup = ucfirst($this->file);
         if ($this->doCoverage) {
             require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
             CodeCoverageManager::init($ucFirstGroup, $Reporter);
             CodeCoverageManager::start();
         }
         $result = $this->Manager->runGroupTest($ucFirstGroup, $Reporter);
         return $result;
     }
     $folder = $folder = $this->__findFolderByCategory($this->category);
     $case = $this->__getFileName($folder, $this->isPluginTest);
     if ($this->doCoverage) {
         require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
         CodeCoverageManager::init($case, $Reporter);
         CodeCoverageManager::start();
     }
     $result = $this->Manager->runTestCase($case, $Reporter);
     return $result;
 }