當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PHPUnit_TextUI_ResultPrinter類代碼示例

本文整理匯總了PHP中PHPUnit_TextUI_ResultPrinter的典型用法代碼示例。如果您正苦於以下問題:PHP PHPUnit_TextUI_ResultPrinter類的具體用法?PHP PHPUnit_TextUI_ResultPrinter怎麽用?PHP PHPUnit_TextUI_ResultPrinter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PHPUnit_TextUI_ResultPrinter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getResultsOutput

 /**
  * @param \PHPUnit_Framework_TestResult[] $results
  */
 public function getResultsOutput(array $results, $output_stream = null)
 {
     assert(is_array($results));
     assert(!empty($results));
     $Printer = new \PHPUnit_TextUI_ResultPrinter($output_stream);
     foreach ($results as $Result) {
         $Printer->printResult($Result);
     }
 }
開發者ID:kakserpom,項目名稱:WakePHP,代碼行數:12,代碼來源:TestCaseRunner.php

示例2: main

function main()
{
    function cleanup()
    {
        global $wpdb;
        // we need to ensure that we switch off this database
        $wpdb->select(null);
        // drop our test database
        // XXX: why cant we use $wpdb->query ?
        mysql_query(sprintf('DROP DATABASE `%s`', DISQUS_TEST_DATABASE)) or die(mysql_error());
    }
    global $wpdb;
    // $this->query(sprintf('DROP DATABASE IF EXISTS `%s`', DISQUS_TEST_DATABASE));
    // check existance of test db
    $exists = $wpdb->get_var($wpdb->prepare('SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = \'%s\'', DISQUS_TEST_DATABASE));
    if (!empty($exists)) {
        printf("Test database '%s' already exists. Continuing will drop this database and all data!\nContinue?  [y/n]\n", $exists);
        $handle = fopen("php://stdin", "r");
        $line = strtolower(trim(fgets($handle)));
        if ($line != 'yes' && $line != 'y') {
            echo "ABORTING!\n";
            exit;
        }
    }
    // setup database
    $wpdb->query(sprintf('CREATE DATABASE `%s`', DISQUS_TEST_DATABASE));
    $wpdb->select(DISQUS_TEST_DATABASE);
    // $fp = fopen('initial.sql', 'r');
    // $buffer = '';
    // while (($line = fgets($fp)) !== false) {
    //     $buffer .= trim($line);
    //     if (strpos($line, ';')) {
    //         if (!empty($buffer)) {
    //             $this->query($buffer);
    //         }
    //         $buffer = '';
    //     }
    // }
    //
    try {
        $suite = new PHPUnit_Framework_TestSuite('DisqusPluginTest');
        $result = $suite->run();
        require_once 'PHPUnit/TextUI/ResultPrinter.php';
        $printer = new PHPUnit_TextUI_ResultPrinter();
        $printer->printResult($result);
        cleanup();
    } catch (Exception $ex) {
        cleanup();
        throw $ex;
    }
}
開發者ID:dannyvankooten,項目名稱:disqus-wordpress,代碼行數:51,代碼來源:tests.php

示例3: pause

 /**
  * @param  boolean $wait
  */
 protected function pause($wait)
 {
     if (!$wait) {
         return;
     }
     if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
         $this->printer->printWaitPrompt();
     }
     fgets(STDIN);
 }
開發者ID:sethcasana,項目名稱:phpunit,代碼行數:13,代碼來源:TestRunner.php

示例4: startTestSuite

 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     if ($this->maxLength == 0) {
         $iterator = new RecursiveIteratorIterator(new PHPUnit_Util_TestSuiteIterator($suite), RecursiveIteratorIterator::SELF_FIRST);
         foreach ($iterator as $item) {
             if ($item instanceof PHPUnit_Framework_TestSuite) {
                 $name = $item->getName();
                 if ($name == '') {
                     $name = '[No name given]';
                 } else {
                     $name = explode('::', $name);
                     $name = array_pop($name);
                 }
                 $this->maxLength = max($this->maxLength, strlen($name));
                 $item->setName($name);
             }
         }
     }
     if ($this->depth > 0) {
         parent::write("\n");
     }
     if ($this->depth == 1) {
         parent::write("\n");
     }
     parent::write(str_pad(str_repeat('  ', $this->depth++) . $suite->getName() . ': ', 40, ' ', STR_PAD_RIGHT));
 }
開發者ID:naderman,項目名稱:ezc-unit-test,代碼行數:26,代碼來源:printer.php

示例5: printFooter

 /**
  * Just add to the output the seed used to randomize the test suite.
  * 
  * @param  PHPUnit_Framework_TestResult $result
  */
 protected function printFooter(\PHPUnit_Framework_TestResult $result)
 {
     parent::printFooter($result);
     $this->writeNewLine();
     $this->write("Randomized with seed: {$this->seed}");
     $this->writeNewLine();
 }
開發者ID:hasumedic,項目名稱:phpunit-randomizer,代碼行數:12,代碼來源:ResultPrinter.php

示例6: endTest

 /**
  * A test ended.
  *
  * @param  PHPUnit_Framework_Test $test
  * @param  float				  $time
  */
 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     parent::endTest($test, $time);
     if ($test instanceof \Pagosoft\PSpec\Test) {
         $this->numAssertions += $test->getNumAssertions();
     }
 }
開發者ID:pago,項目名稱:pantr,代碼行數:13,代碼來源:ResultPrinter.php

示例7: writeProgress

 /**
  * {@inheritdoc}
  */
 protected function writeProgress($progress)
 {
     if ($progress == '.') {
         $progress = $this->fab->paintChar('*');
     }
     parent::writeProgress($progress);
 }
開發者ID:whatthejeff,項目名稱:fab-phpunit-resultprinter,代碼行數:10,代碼來源:ResultPrinter.php

示例8: endTestSuite

 /**
  * @param PHPUnit_Framework_TestSuite $suite
  * @since Method available since Release 2.7.0
  */
 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $oldVerbose = $this->verbose;
     $this->verbose = false;
     parent::endTestSuite($suite);
     $this->verbose = $oldVerbose;
 }
開發者ID:kumatch,項目名稱:stagehand-testrunner,代碼行數:11,代碼來源:ResultPrinter.php

示例9: pause

 /**
  * @param  boolean $wait
  * @access protected
  */
 protected function pause($wait)
 {
     if (!$wait) {
         return;
     }
     $this->fPrinter->printWaitPrompt();
     fgets(STDIN);
 }
開發者ID:amjadtbssm,項目名稱:website,代碼行數:12,代碼來源:TestRunner.php

示例10: printDefectTrace

 protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect)
 {
     global $CFG;
     parent::printDefectTrace($defect);
     $failedTest = $defect->failedTest();
     $testName = get_class($failedTest);
     $exception = $defect->thrownException();
     $trace = $exception->getTrace();
     if (class_exists('ReflectionClass')) {
         $reflection = new ReflectionClass($testName);
         $file = $reflection->getFileName();
     } else {
         $file = false;
         $dirroot = realpath($CFG->dirroot) . DIRECTORY_SEPARATOR;
         $classpath = realpath("{$CFG->dirroot}/lib/phpunit/classes") . DIRECTORY_SEPARATOR;
         foreach ($trace as $item) {
             if (strpos($item['file'], $dirroot) === 0 and strpos($item['file'], $classpath) !== 0) {
                 if ($content = file_get_contents($item['file'])) {
                     if (preg_match('/class\\s+' . $testName . '\\s+extends/', $content)) {
                         $file = $item['file'];
                         break;
                     }
                 }
             }
         }
     }
     if ($file === false) {
         return;
     }
     $cwd = getcwd();
     if (strpos($file, $cwd) === 0) {
         $file = substr($file, strlen($cwd) + 1);
     }
     $executable = null;
     if (isset($_SERVER['argv'][0])) {
         if (preg_match('/phpunit(\\.bat|\\.cmd)?$/', $_SERVER['argv'][0])) {
             $executable = $_SERVER['argv'][0];
             for ($i = 1; $i < count($_SERVER['argv']); $i++) {
                 if (!isset($_SERVER['argv'][$i])) {
                     break;
                 }
                 if (in_array($_SERVER['argv'][$i], array('--colors', '--verbose', '-v', '--debug', '--strict'))) {
                     $executable .= ' ' . $_SERVER['argv'][$i];
                 }
             }
         }
     }
     if (!$executable) {
         $executable = 'phpunit';
         if (testing_is_cygwin()) {
             $file = str_replace('\\', '/', $file);
             if (!testing_is_mingw()) {
                 $executable = 'phpunit.bat';
             }
         }
     }
     $this->write("\nTo re-run:\n {$executable} {$testName} {$file}\n");
 }
開發者ID:janaece,項目名稱:globalclassroom4_clean,代碼行數:58,代碼來源:hint_resultprinter.php

示例11: printFooter

 protected function printFooter(PHPUnit_Framework_TestResult $result)
 {
     $this->write('<div class="stats">');
     parent::printFooter($result);
     $this->write('</div>');
     $this->write('<div class="resourceUsage">');
     $this->write(PHP_Timer::resourceUsage());
     $this->write('</div>');
 }
開發者ID:kshyana,項目名稱:PHP-TestKit,代碼行數:9,代碼來源:TestKit_Printer.php

示例12: __construct

 public function __construct($backtrace, $colors = false)
 {
     parent::__construct(null, false, $colors);
     $this->backtrace = '';
     foreach ($backtrace as $trace) {
         if (isset($trace['file']) && isset($trace['line'])) {
             $this->backtrace .= $trace['file'] . ':' . $trace['line'] . "\n";
         }
     }
 }
開發者ID:skerbis,項目名稱:redaxo,代碼行數:10,代碼來源:tests_result_printer.php

示例13: doRun

 /**
  * @param  PHPUnit_Framework_Test $suite
  * @param  array                   $parameters
  * @return PHPUnit_Framework_TestResult
  * @access public
  */
 public function doRun(PHPUnit_Framework_Test $suite, array $parameters = array())
 {
     $parameters['repeat'] = isset($parameters['repeat']) ? $parameters['repeat'] : FALSE;
     $parameters['filter'] = isset($parameters['filter']) ? $parameters['filter'] : FALSE;
     $parameters['verbose'] = isset($parameters['verbose']) ? $parameters['verbose'] : FALSE;
     if (is_integer($parameters['repeat'])) {
         $suite = new PHPUnit_Extensions_RepeatedTest($suite, $parameters['repeat']);
     }
     if (isset($parameters['reportDirectory'])) {
         $parameters['reportDirectory'] = $this->getDirectory($parameters['reportDirectory']);
     }
     $result = $this->createTestResult();
     if ($this->printer === NULL) {
         $this->printer = $parameters['xml'] ? new CopixTestXMLPrinter(NULL, $parameters['verbose']) : new CopixTestPrinter(NULL, $parameters['verbose']);
     }
     $result->addListener($this->printer);
     if (isset($parameters['testdoxHTMLFile'])) {
         $result->addListener(PHPUnit_Util_TestDox_ResultPrinter::factory('HTML', $parameters['testdoxHTMLFile']));
     }
     if (isset($parameters['testdoxTextFile'])) {
         $result->addListener(PHPUnit_Util_TestDox_ResultPrinter::factory('Text', $parameters['testdoxTextFile']));
     }
     if (isset($parameters['graphvizLogfile'])) {
         if (class_exists('Image_GraphViz', FALSE) && class_exists('PHPUnit_Util_Log_GraphViz', FALSE)) {
             $result->addListener(new PHPUnit_Util_Log_GraphViz($parameters['graphvizLogfile']));
         }
     }
     if (isset($parameters['reportDirectory']) && extension_loaded('xdebug')) {
         if (class_exists('Image_GraphViz', FALSE) && class_exists('PHPUnit_Util_Report_GraphViz', FALSE)) {
             $result->addListener(new PHPUnit_Util_Report_GraphViz($parameters['reportDirectory']));
         }
         $result->collectCodeCoverageInformation(TRUE);
     }
     if (isset($parameters['jsonLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_JSON($parameters['jsonLogfile']));
     }
     if (isset($parameters['tapLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_TAP($parameters['tapLogfile']));
     }
     if (isset($parameters['xmlLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_XML($parameters['xmlLogfile']));
     }
     $suite->run($result, $parameters['filter']);
     $result->flushListeners();
     if (isset($parameters['reportDirectory']) && extension_loaded('xdebug')) {
         $this->printer->codeCoverage($parameters['reportDirectory']);
         PHPUnit_Util_Report::render($result, $parameters['reportDirectory']);
     } else {
         $this->printer->codeCoverage(false);
     }
     if ($this->printer) {
         $this->printer->printResult($result);
     }
     return $result;
 }
開發者ID:JVS-IS,項目名稱:ICONITO-EcoleNumerique,代碼行數:61,代碼來源:CopixTestRunner.class.php

示例14: write

 /**
  * @param string $buffer
  * @since  Method available since Release 3.1.0
  */
 protected function write($buffer)
 {
     if (PHP_SAPI != 'cli') {
         $buffer = htmlspecialchars($buffer);
     }
     if ($this->printer !== null) {
         $this->printer->write($buffer);
     } else {
         print $buffer;
     }
 }
開發者ID:mubassirhayat,項目名稱:Laravel51-starter,代碼行數:15,代碼來源:TestRunner.php

示例15: printDefectTrace

 protected function printDefectTrace(\PHPUnit_Framework_TestFailure $defect)
 {
     $e = $defect->thrownException();
     if (!$e instanceof \atk4\core\PHPUnit_AgileExceptionWrapper) {
         return parent::printDefectTrace($defect);
     }
     $this->write((string) $e);
     $p = $e->getPrevious();
     if ($p instanceof \atk4\core\Exception or $p instanceof \atk4\dsql\Exception) {
         $this->write($p->getColorfulText());
     }
 }
開發者ID:atk4,項目名稱:core,代碼行數:12,代碼來源:PHPUnit_AgileResultPrinter.php


注:本文中的PHPUnit_TextUI_ResultPrinter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。